示例#1
0
function mobile_get_full_game_update()
{
    if ($_GET['gameid'] != "") {
        $config = $Root_Path . "bin/config.php";
        $session = base64_decode($_GET['sid']);
        list($uniq, $player_id) = preg_split("/\\|/", $session);
        $oR3DCQuery = new CR3DCQuery($config);
        ChessHelper::load_chess_game($_GET['gameid']);
        echo "<PGN>";
        echo ChessHelper::get_game_pgn();
        echo "</PGN>\n";
        $pieces = ChessHelper::get_captured_pieces();
        echo "<CAPTURED_BY_WHITE>" . join(', ', $pieces['white']) . "</CAPTURED_BY_WHITE>\n";
        echo "<CAPTURED_BY_BLACK>" . join(', ', $pieces['black']) . "</CAPTURED_BY_BLACK>\n";
        echo "<GAME_STATE>";
        echo ChessHelper::get_game_state();
        echo "</GAME_STATE>\n";
        echo "<GAME_RESULT>";
        echo ChessHelper::get_game_result();
        echo "</GAME_RESULT>\n";
        $isblack = $oR3DCQuery->IsPlayerBlack($config, $_GET['gameid'], $player_id);
        $isdraw = $oR3DCQuery->IsRequestDraw($config, $_GET['gameid'], $isblack);
        echo "<DRAWCODE>";
        echo $isdraw;
        echo "</DRAWCODE>\n";
        $timeinfo = ChessHelper::get_timing_info();
        $str = "<TIME_STARTED>" . $timeinfo['started'] . "</TIME_STARTED>";
        $str .= "<TIME_TYPE>" . $timeinfo['type'] . "</TIME_TYPE>";
        $str .= '<TIME_MODE>' . $timeinfo['mode'] . '</TIME_MODE>';
        if ($timeinfo['mode'] == 1) {
            $str .= '<TIME_W_LEFT>' . $timeinfo['w_time_left'] . '</TIME_W_LEFT>';
            $str .= '<TIME_B_LEFT>' . $timeinfo['b_time_left'] . '</TIME_B_LEFT>';
            $str .= '<TIME_W_ALLOWED>' . $timeinfo['w_time_allowed'] . '</TIME_W_ALLOWED>';
            $str .= '<TIME_B_ALLOWED>' . $timeinfo['b_time_allowed'] . '</TIME_B_ALLOWED>';
        } else {
            $str .= "<TIME_DURATION>" . $timeinfo['duration'] . "</TIME_DURATION>";
            $str .= '<TIME_W_ALLOWED>' . $timeinfo['duration'] . '</TIME_W_ALLOWED>';
            $str .= '<TIME_B_ALLOWED>' . $timeinfo['duration'] . '</TIME_B_ALLOWED>';
        }
        echo $str;
    } else {
        echo "<ERROR>IDS_GAME_ID_INVALID</ERROR>\n";
    }
}
$str = "<RESPONSE><PGN>";
$str .= ChessHelper::get_game_pgn();
$str .= "</PGN>\n";
$pieces = ChessHelper::get_captured_pieces();
$str .= "<CAPTURED_BY_WHITE>" . join(', ', $pieces['white']) . "</CAPTURED_BY_WHITE>\n";
$str .= "<CAPTURED_BY_BLACK>" . join(', ', $pieces['black']) . "</CAPTURED_BY_BLACK>\n";
$str .= "<GAME_STATE>";
$str .= ChessHelper::get_game_state();
$str .= "</GAME_STATE>\n";
$str .= "<GAME_RESULT>";
$str .= ChessHelper::get_game_result();
$str .= "</GAME_RESULT>\n";
$str .= "<DRAWCODE>";
$str .= $oR3DCQuery->IsRequestDraw($config, $_GET['gameid'], $player == 'black' ? TRUE : FALSE);
$str .= "</DRAWCODE>\n";
$timeinfo = ChessHelper::get_timing_info();
$str .= "<TIME_STARTED>" . $timeinfo['started'] . "</TIME_STARTED>\n";
$str .= "<TIME_TYPE>" . $timeinfo['type'] . "</TIME_TYPE>\n";
$str .= '<TIME_MODE>' . $timeinfo['mode'] . '</TIME_MODE>\\n';
if ($timeinfo['mode'] == 1) {
    $str .= '<TIME_W_LEFT>' . $timeinfo['w_time_left'] . '</TIME_W_LEFT>';
    $str .= '<TIME_B_LEFT>' . $timeinfo['b_time_left'] . '</TIME_B_LEFT>';
    $str .= '<TIME_W_ALLOWED>' . $timeinfo['w_time_allowed'] . '</TIME_W_ALLOWED>';
    $str .= '<TIME_B_ALLOWED>' . $timeinfo['b_time_allowed'] . '</TIME_B_ALLOWED>';
} else {
    $str .= "<TIME_DURATION>" . $timeinfo['duration'] . "</TIME_DURATION>\n";
    $str .= '<TIME_W_ALLOWED>' . $timeinfo['duration'] . '</TIME_W_ALLOWED>';
    $str .= '<TIME_B_ALLOWED>' . $timeinfo['duration'] . '</TIME_B_ALLOWED>';
}
$str .= "</RESPONSE>\n";
echo preg_replace("/\n/", "", addslashes($str));