try { Player::check_database($username, $email, $player_id); } catch (MyException $e) { echo $e->getCode(); exit; } break; default: break; } echo 'OK'; exit; } // run the custom trade table builder if (isset($_POST['custom_trades'])) { echo trade_value_table(Game::calculate_trade_values($_POST['custom_trades'])); exit; } // run the in game chat if (isset($_POST['chat'])) { try { if (!isset($_SESSION['game_id'])) { $_SESSION['game_id'] = 0; } $Chat = new Chat((int) $_SESSION['player_id'], (int) $_SESSION['game_id']); $Chat->send_message($_POST['chat'], isset($_POST['private']), isset($_POST['lobby'])); $return = $Chat->get_box_list(1); $return = $return[0]; } catch (MyException $e) { $return['error'] = 'ERROR: ' . $e->outputMessage(); }
/** * Generates and returns the game info box html * * @param $Game Game object * * @return string game info html */ function game_info($Game) { ob_start(); ?> <div id="game_info"> <h2>Risk Analysis</h2> <?php $player_data = $Game->get_players_visible_data(); unset($player_data[0]); // current player for un-started review games unset($player_data['']); // host for review games $ra_table_meta = array('sortable' => true, 'no_data' => '<p>There are no players to show</p>', 'class' => 'datatable users'); $ra_table_format = array(array('SPECIAL_CLASS', 'true', '###substr(\'[[[color]]]\', 0, 3).((\'Dead\' == \'[[[state]]]\') ? \' dead\' : \'\')'), array('Order', 'order'), array('Player', 'username'), array('State', 'state'), array('Round', 'round'), array('Turn', 'turn'), array('Armies', 'armies'), array('Land', 'land'), array('Conts', 'cont_list'), array('Cards', 'card_count'), array('% trade', 'trade_perc'), array('Next turn', '[[[next_armies]]] / [[[next_armies_trade]]]')); echo get_table($ra_table_format, $player_data, $ra_table_meta); ?> <table class="game_info"> <tbody> <tr> <th>Game Type</th> <td><?php echo $Game->get_type(); ?> </td> </tr><tr> <th>Placement Type</th> <td><?php echo $Game->get_placement(); ?> </td> </tr><tr> <th>Placement Limit</th> <td><?php echo $Game->get_placement_limit(); ?> </td> </tr><tr> <th>Fortification Type</th> <td><?php echo $Game->get_fortify(); ?> </td> </tr><tr> <th>Kamikaze</th> <td><?php echo $Game->get_kamikaze(); ?> </td> </tr><tr> <th>Warmonger</th> <td><?php echo $Game->get_warmonger(); ?> </td> </tr><tr> <th>Fog of War</th> <td><?php $fog_of_war = $Game->get_fog_of_war(); echo 'Armies: ' . $fog_of_war['armies'] . '<br />Colors: ' . $fog_of_war['colors']; ?> </td> </tr><tr> <th>Trade Count</th> <td><?php echo $Game->get_trade_count(); ?> </td> </tr><tr> <th>Custom Trade Array</th> <td><?php $trades = $Game->get_trade_array(); if (!$trades) { echo 'None'; } else { echo '<table>'; echo '<thead><tr><th>Start</th><th>End</th><th>Step</th><th>Times</th></tr></thead>'; echo '<tbody>'; $n = 0; foreach ($trades as $trade) { if (!isset($trade[3])) { $trade[3] = 0; } ++$n; echo '<tr' . (0 === $n % 2 ? ' class="alt"' : '') . '><td>' . $trade[0] . '</td><td>' . $trade[1] . '</td><td>' . $trade[2] . '</td><td>' . $trade[3] . '</td></tr>'; } echo '</tbody></table>'; } ?> </td> </tr><tr> <th>Trade Card Bonus</th> <td><?php echo $Game->get_trade_card_bonus(); ?> </td> </tr><tr> <th>Conquer Limit</th> <td><?php echo $Game->get_conquer_limit(); ?> </td> </tr><tr> <th>Custom Rules</th> <td><?php echo htmlentities($Game->get_custom_rules(), ENT_QUOTES, 'UTF-8', false); ?> </td> </tr> </tbody> </table> <!-- .game_info --> <?php echo conquer_limit_table($Game); ?> <table class="datatable custom_trades"> <caption>Trade Values</caption> <thead> <tr> <th>Trade #</th> <th>Value</th> </tr> </thead> <tbody> <?php echo trade_value_table($Game); ?> </tbody> </table> <!-- .custom_trades --> </div> <!-- #game_info --> <?php $html = ob_get_clean(); return $html; }
$trade_array_table = 'None'; if ($trades) { $trade_array_table = '<table>'; $trade_array_table .= '<thead><tr><th>Start</th><th>End</th><th>Step</th><th>Times</th></tr></thead>'; $trade_array_table .= '<tbody>'; $n = 0; foreach ($trades as $trade) { if (!isset($trade[3])) { $trade[3] = 0; } ++$n; $trade_array_table .= '<tr' . (0 === $n % 2 ? ' class="alt"' : '') . '><td>' . $trade[0] . '</td><td>' . $trade[1] . '</td><td>' . $trade[2] . '</td><td>' . $trade[3] . '</td></tr>'; } $trade_array_table .= '</tbody></table>'; } $trade_value_table = trade_value_table(Game::calculate_trade_values($trades)); $contents = ' <h2>Game #' . $_GET['id'] . ': ' . htmlentities($Game->name, ENT_QUOTES, 'UTF-8', false) . '</h2> <table class="game_info"> <tbody> <tr> <th>Game Type</th> <td>' . $Game->get_type() . '</td> </tr><tr> <th>Max Players</th> <td>' . $Game->capacity . '</td> </tr><tr> <th>Placement Type</th> <td>' . $Game->get_placement() . '</td> </tr><tr>