// load the game // always refresh the game data, there may be more than one person online try { $Game = new Game((int) $_SESSION['game_id']); $players = $Game->get_players(); } catch (MyException $e) { if (!defined('DEBUG') || !DEBUG) { Flash::store('Error Accessing Game !'); } else { call('ERROR ACCESSING GAME :' . $e->outputMessage()); } exit; } // MOST FORM SUBMISSIONS ARE AJAXED THROUGH /scripts/game.js // game buttons and moves are passed through the game controller if (!$Game->is_player($_SESSION['player_id'])) { $Game->watch_mode = true; $chat_html = ''; unset($Chat); } if (!$Game->watch_mode || $GLOBALS['Player']->is_admin) { $Chat = new Chat($_SESSION['player_id'], $_SESSION['game_id']); $chat_data = $Chat->get_box_list(); $chat_html = ' <div id="chatbox"> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post"><div> <input id="chat" type="text" name="chat" /> <label for="private" class="inline"><input type="checkbox" name="private" id="private" value="yes" /> Private</label> </div></form> <dl id="chats">'; if (is_array($chat_data)) {
} // preserve spaces in the chat text $chat['message'] = htmlentities($chat['message'], ENT_QUOTES, 'ISO-8859-1', false); $chat['message'] = str_replace("\t", ' ', $chat['message']); $chat['message'] = str_replace(' ', ' ', $chat['message']); $chat_html .= ' <dt class="' . $color . '"><span>' . $chat['create_date'] . '</span> ' . $chat['username'] . '</dt> <dd' . ($chat['private'] ? ' class="private"' : '') . '>' . $chat['message'] . '</dd>'; } $chat_html .= ' </dl> <!-- #chats -->'; } $chat_html .= ' </div> <!-- #chatbox -->'; // hide the chat from non-players if ('Finished' == $Game->state && !$Game->is_player($_SESSION['player_id'])) { $chat_html = ''; } $win_text = ''; $turn = $Game->get_my_turn() ? 'Your Turn' : $Game->name . '\'s Turn'; $no_turn = false; if ($Game->paused) { $turn = 'PAUSED'; $no_turn = true; } elseif ('Finished' == $Game->state) { $turn = 'GAME OVER'; $no_turn = true; list($win_text, $outcome, $outcome_data) = $Game->get_outcome($_SESSION['player_id']); } $info_bar = '<span class="turn">' . $turn . '</span>'; $matching_methods = $Game->get_matching_methods();
Flash::store('Game Invitations Sent Successfully'); } catch (MyException $e) { Flash::store('Game Invite FAILED !'); } } if (isset($_POST['start'])) { test_token(); try { $Game->start((int) $_POST['player_id']); Flash::store('Game Started Successfully', 'game.php?id=' . $_POST['game_id']); } catch (MyException $e) { Flash::store('Game Start FAILED !', true); } } // test if we are already in this game or not $joined = $Game->is_player($_SESSION['player_id']); $color_selection = ''; foreach ($Game->get_avail_colors() as $color) { $color_selection .= '<option class="' . strtolower(substr($color, 0, 3)) . '">' . ucfirst($color) . '</option>'; } $password_box = ''; if ('' != $Game->passhash) { $password_box = '<li><label for="password">Password</label><input type="password" id="password" name="password" /></li>'; } $meta['title'] = 'Join Game'; $meta['head_data'] = ' <script type="text/javascript">//<![CDATA[ $(document).ready( function( ) { $("#show_conquer_limit_table").fancybox({ title: null, beforeLoad: function( ) {