当前位置: 首页>>代码示例>>PHP>>正文


PHP SmrSession::game_id方法代码示例

本文整理汇总了PHP中SmrSession::game_id方法的典型用法代码示例。如果您正苦于以下问题:PHP SmrSession::game_id方法的具体用法?PHP SmrSession::game_id怎么用?PHP SmrSession::game_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmrSession的用法示例。


在下文中一共展示了SmrSession::game_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_file_loc

<?php

require_once get_file_loc('smr_sector.inc');
// register game_id
SmrSession::$game_id = $var["game_id"];
// check if hof entry is there
$db->query("SELECT * FROM account_has_stats WHERE account_id = " . SmrSession::$old_account_id);
if (!$db->nf()) {
    $db->query("INSERT INTO account_has_stats (account_id, HoF_name, games_joined) VALUES ({$account->account_id}, " . format_string($account->login, true) . ", 1)");
}
$player = new SMR_PLAYER(SmrSession::$old_account_id, $var["game_id"]);
include get_file_loc('out_check.php');
$player->last_sector_id = 0;
$player->last_active = time();
$player->update();
// get rid of old plotted course
$player->delete_plotted_course();
// log
$account->log(2, "Player entered game " . SmrSession::$game_id, $player->sector_id);
$container = array();
$container["url"] = "skeleton.php";
if ($player->land_on_planet == "TRUE") {
    $container["body"] = "planet_main.php";
} else {
    $container["body"] = "current_sector.php";
}
require_once get_file_loc('smr_alliance.inc');
require_once get_file_loc("smr_force.inc");
require_once get_file_loc("smr_planet.inc");
require_once get_file_loc("smr_port.inc");
require_once get_file_loc('smr_sector.inc');
开发者ID:smrealms,项目名称:smrv2.0,代码行数:31,代码来源:game_play_processing.php

示例2: writeToEngine

 }
 function writeToEngine($s, $block = true, $read = true)
 {
     global $toEngine;
     debug('--> ' . $s);
     fputs($toEngine, $s . EOL);
     if ($read === true) {
         readFromEngine($block);
     }
 }
 readFromEngine();
 writeToEngine('uci');
 writeToEngine('setoption name Hash value ' . UCI_HASH_SIZE_MB, false);
 writeToEngine('isready');
 writeToEngine('ucinewgame', false);
 SmrSession::$game_id = NPC_GAME_ID;
 require_once get_file_loc('ChessGame.class.inc');
 while (true) {
     //Redefine MICRO_TIME and TIME, the rest of the game expects them to be the single point in time that the script is executing, with it being redefined for each page load - unfortunately NPCs are one consistent script so we have to do a hack and redefine it (or change every instance of the TIME constant).
     runkit_constant_redefine('MICRO_TIME', microtime());
     runkit_constant_redefine('TIME', (int) microtimeSec(MICRO_TIME));
     $chessGames =& ChessGame::getNPCMoveGames(true);
     foreach ($chessGames as &$chessGame) {
         debug('Looking at game: ' . $chessGame->getChessGameID());
         writeToEngine('position fen ' . $chessGame->getFENString(), false);
         writeToEngine('go ' . ($chessGame->getCurrentTurnColour() == ChessGame::PLAYER_WHITE ? 'w' : 'b') . 'time ' . UCI_TIME_PER_MOVE_MS, true, false);
         stream_set_blocking($fromEngine, 1);
         while (stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) {
             debug('<-- ' . $move);
             if (stripos($move, 'Seg') === 0) {
                 // Segfault
开发者ID:smrealms,项目名称:smrv2.0,代码行数:31,代码来源:chess.php

示例3: changeNPCLogin

function changeNPCLogin()
{
    global $NPC_LOGIN, $actions, $NPC_LOGINS_USED, $underAttack, $previousContainer;
    if ($actions > 0) {
        debug('We have taken actions and now want to change NPC, let\'s exit and let next script choose a new NPC to reset execution time', getrusage());
        exitNPC();
    }
    $actions = -1;
    $GLOBALS['TRADE_ROUTE'] = null;
    $db = new SmrMySqlDatabase();
    $db->query('UPDATE npc_logins SET working=' . $db->escapeBoolean(false) . ' WHERE login=' . $db->escapeString($NPC_LOGIN['Login']));
    if ($db->getChangedRows() > 0) {
        debug('Unlocked NPC: ' . $NPC_LOGIN['Login']);
    } else {
        debug('Failed to unlock NPC: ' . $NPC_LOGIN['Login']);
    }
    $NPC_LOGIN = null;
    // We chose a new NPC, we don't care what we were doing beforehand.
    $previousContainer = null;
    debug('Choosing new NPC');
    $db2 = new SmrMySqlDatabase();
    $db->query('SELECT login, npc.player_name, alliance_name
				FROM npc_logins npc
				LEFT JOIN account a USING(login)
				LEFT JOIN player p ON a.account_id = p.account_id AND p.game_id = ' . $db->escapeNumber(NPC_GAME_ID) . '
				WHERE active=' . $db->escapeBoolean(true) . ' AND working=' . $db->escapeBoolean(false) . ' AND login NOT IN (' . $db->escapeArray($NPC_LOGINS_USED) . ')
				ORDER BY (turns IS NOT NULL), turns DESC');
    while ($db->nextRecord()) {
        $db2->query('UPDATE npc_logins SET working=' . $db2->escapeBoolean(true) . ' WHERE login=' . $db2->escapeString($db->getField('login')) . ' AND working=' . $db2->escapeBoolean(false));
        if ($db2->getChangedRows() > 0) {
            $NPC_LOGIN = array('Login' => $db->getField('login'), 'PlayerName' => $db->getField('player_name'), 'AllianceName' => $db->getField('alliance_name'));
            break;
        }
    }
    $NPC_LOGINS_USED[] = $NPC_LOGIN['Login'];
    if ($NPC_LOGIN === null) {
        debug('No free NPCs');
        exitNPC();
    }
    debug('Chosen NPC: ' . $NPC_LOGIN['Login']);
    if (SmrAccount::getAccountByName($NPC_LOGIN['Login']) == null) {
        debug('Creating account for: ' . $NPC_LOGIN['Login']);
        $account =& SmrAccount::createAccount($NPC_LOGIN['Login'], '', 'NPC@smrealms.de', 'NPC', 'NPC', 'NPC', 'NPC', 'NPC', 'NPC', 'NPC', 0, 0);
        $account->setValidated(true);
    } else {
        $account =& SmrAccount::getAccountByName($NPC_LOGIN['Login']);
    }
    $GLOBALS['account'] =& $account;
    SmrSession::$account_id = $account->getAccountID();
    $underAttack = false;
    //Auto-create player if need be.
    $db->query('SELECT 1 FROM player WHERE account_id = ' . $account->getAccountID() . ' AND game_id = ' . NPC_GAME_ID . ' LIMIT 1');
    if (!$db->nextRecord()) {
        SmrSession::$game_id = 0;
        //Have to be out of game to join game.
        debug('Auto-creating player: ' . $account->getLogin());
        processContainer(joinGame(SmrSession::$game_id, $NPC_LOGIN['PlayerName']));
    }
    throw new Exception('Forward');
}
开发者ID:smrealms,项目名称:smrv2.0,代码行数:60,代码来源:npc.php

示例4: echoChessMoves

<?php

require_once '../htdocs/config.inc';
require_once LIB . 'Default/Globals.class.inc';
require_once get_file_loc('ChessGame.class.inc');
SmrSession::$game_id = 44;
$db = new SmrMySqlDatabase();
$db->query('DELETE FROM player_hof WHERE type LIKE \'Chess%\'');
$db->query('SELECT chess_game_id FROM chess_game');
while ($db->nextRecord()) {
    $chessGameID = $db->getInt('chess_game_id');
    $game =& ChessGame::getChessGame($chessGameID);
    echo 'Running game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() . '", winner "' . $game->getWinner() . '"' . EOL;
    echoChessMoves($game);
    $game->rerunGame(true);
    echo 'Finished game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() . '", winner "' . $game->getWinner() . '"' . EOL;
    echoChessMoves($game);
}
function echoChessMoves($game)
{
    echo 'Moves: ' . EOL;
    $moves = $game->getMoves();
    foreach ($moves as $move) {
        echo $move . EOL;
    }
    echo EOL;
}
开发者ID:smrealms,项目名称:smrv2.0,代码行数:27,代码来源:rerunChessGames.php

示例5:

<?php

// register game_id
SmrSession::$game_id = $var['game_id'];
$player =& SmrPlayer::getPlayer(SmrSession::$account_id, $var['game_id']);
$player->updateLastCPLAction();
// get rid of old plotted course
$player->deletePlottedCourse();
$player->update();
// log
$account->log(LOG_TYPE_GAME_ENTERING, 'Player entered game ' . SmrSession::$game_id, $player->getSectorID());
$container = create_container('skeleton.php');
if ($player->isLandedOnPlanet()) {
    $container['body'] = 'planet_main.php';
} else {
    $container['body'] = 'current_sector.php';
}
forward($container);
开发者ID:smrealms,项目名称:smrv2.0,代码行数:18,代码来源:game_play_processing.php


注:本文中的SmrSession::game_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。