if (isset($_POST['invite'])) { call($_POST); // make sure this user is not full if ($GLOBALS['Player']->max_games && $GLOBALS['Player']->max_games <= $GLOBALS['Player']->current_games) { Flash::store('You have reached your maximum allowed games !', false); } test_token(); try { Game::invite(); Flash::store('Invitation Sent Successfully', true); } catch (MyException $e) { Flash::store('Invitation FAILED !', false); } } // grab the full list of players $players_full = GamePlayer::get_list(true); $invite_players = array_shrink($players_full, 'player_id'); $invite_players = ife($invite_players, array(), false); // grab the players who's max game count has been reached $players_maxed = GamePlayer::get_maxed(); $players_maxed[] = $_SESSION['player_id']; // remove the maxed players from the invite list $players = array_diff($invite_players, $players_maxed); $opponent_selection = ''; $opponent_selection .= '<option value="">-- Open --</option>'; foreach ($players_full as $player) { if ($_SESSION['player_id'] == $player['player_id']) { continue; } if (in_array($player['player_id'], $players)) { $opponent_selection .= '
Settings::write_all($POST); Flash::store('Admin Update Successfull', true); // redirect kills form resubmission } catch (MyException $e) { Flash::store('Admin Update FAILED !', true); // redirect kills form resubmission } } $meta['title'] = GAME_NAME . ' Administration'; $meta['head_data'] = ' <script type="text/javascript" src="scripts/admin.js"></script> '; $hints = array('Here you can administrate your ' . GAME_NAME . ' installation.', 'Click anywhere on a row to mark that row for action.'); $contents = ''; // grab the lists $player_list = GamePlayer::get_list(); $game_list = Game::get_list(); // go through the player list and remove the root admin and ourselves foreach ($player_list as $key => $player) { if ($GLOBALS['_ROOT_ADMIN'] == $player['username']) { unset($player_list[$key]); } if ($_SESSION['player_id'] == $player['player_id']) { unset($player_list[$key]); } } $table_meta = array('sortable' => true, 'no_data' => '<p>There are no players to show</p><!-- NO_PLAYERS -->', 'caption' => 'Players'); $table_format = array(array('ID', 'player_id'), array('Player', 'username'), array('First Name', 'first_name'), array('Last Name', 'last_name'), array('Email', 'email'), array('Admin', '###(([[[full_admin]]] | [[[half_admin]]]) ? \'<span class="notice">Yes</span>\' : \'No\')'), array('Approved', '###(([[[is_approved]]]) ? \'Yes\' : \'<span class="notice">No</span>\')'), array('Last Online', '###date(Settings::read(\'long_date\'), strtotime(\'[[[last_online]]]\'))', null, ' class="date"'), array('<input type="checkbox" id="player_all" />', '<input type="checkbox" name="ids[]" value="[[[player_id]]]" class="player_box" />', 'false', 'class="edit"')); $table = get_table($table_format, $player_list, $table_meta); if (false === strpos($table, 'NO_PLAYERS')) { $contents .= '
/** static public function get_player_stats_list * Returns a list array of all game players * in the database with additional stats added * * @param void * @return array game player list (or bool false on failure) */ public static function get_player_stats_list() { $Mysql = Mysql::get_instance(); $players = GamePlayer::get_list(true); if ($players) { // add some more stats $query = "\n\t\t\t\tSELECT o.player_id\n\t\t\t\t\t, COUNT(ww.win) AS white_wins\n\t\t\t\t\t, COUNT(wl.win) AS white_losses\n\t\t\t\t\t, COUNT(wd.win) AS white_draws\n\t\t\t\t\t, COUNT(bw.win) AS black_wins\n\t\t\t\t\t, COUNT(bl.win) AS black_losses\n\t\t\t\t\t, COUNT(bd.win) AS black_draws\n\t\t\t\tFROM " . self::GAME_STATS_TABLE . " AS o\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS ww\n\t\t\t\t\t\tON (o.player_id = ww.player_id\n\t\t\t\t\t\t\tAND o.game_id = ww.game_id\n\t\t\t\t\t\t\tAND ww.win = 1\n\t\t\t\t\t\t\tAND ww.color = 'white')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS wl\n\t\t\t\t\t\tON (o.player_id = wl.player_id\n\t\t\t\t\t\t\tAND o.game_id = wl.game_id\n\t\t\t\t\t\t\tAND wl.win = -1\n\t\t\t\t\t\t\tAND wl.color = 'white')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS wd\n\t\t\t\t\t\tON (o.player_id = wd.player_id\n\t\t\t\t\t\t\tAND o.game_id = wd.game_id\n\t\t\t\t\t\t\tAND wd.win = 0\n\t\t\t\t\t\t\tAND wd.color = 'white')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS bw\n\t\t\t\t\t\tON (o.player_id = bw.player_id\n\t\t\t\t\t\t\tAND o.game_id = bw.game_id\n\t\t\t\t\t\t\tAND bw.win = 1\n\t\t\t\t\t\t\tAND bw.color = 'black')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS bl\n\t\t\t\t\t\tON (o.player_id = bl.player_id\n\t\t\t\t\t\t\tAND o.game_id = bl.game_id\n\t\t\t\t\t\t\tAND bl.win = -1\n\t\t\t\t\t\t\tAND bl.color = 'black')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS bd\n\t\t\t\t\t\tON (o.player_id = bd.player_id\n\t\t\t\t\t\t\tAND o.game_id = bd.game_id\n\t\t\t\t\t\t\tAND bd.win = 0\n\t\t\t\t\t\t\tAND bd.color = 'black')\n\t\t\t\tGROUP BY o.player_id\n\t\t\t"; $results = $Mysql->fetch_array($query); $stats = array(); foreach ($results as $stat) { $stats[$stat['player_id']] = $stat; } $empty = array('white_wins' => 0, 'white_losses' => 0, 'white_draws' => 0, 'black_wins' => 0, 'black_losses' => 0, 'black_draws' => 0); foreach ($players as &$player) { // be careful with the reference if (isset($stats[$player['player_id']])) { $player = array_merge($player, $stats[$player['player_id']]); } else { $player = array_merge($player, $empty); } } unset($player); // kill the reference } return $players; }
var $elem = $(elem); var text = parseFloat($elem.text( )); if (0 < text) { $elem.css("color", "green"); } else if (0 > text) { $elem.css("color", "red"); } }); }); //]]></script> '; $hints = array('View ' . GAME_NAME . ' Player and Game statistics.', 'A Kill is when you eradicate a player from the game.'); // grab the wins and losses for the players $list = GamePlayer::get_list(true); $table_meta = array('sortable' => true, 'no_data' => '<p>There are no player stats to show</p>', 'caption' => 'Player Stats', 'init_sort_column' => array(1 => 1)); $table_format = array(array('Player', 'username'), array('Wins', 'wins'), array('Kills', 'kills'), array('Losses', 'losses'), array('Win-Loss', '###([[[wins]]] - [[[losses]]])', null, ' class="color"'), array('Win %', '###((0 != ([[[wins]]] + [[[losses]]])) ? perc([[[wins]]] / ([[[wins]]] + [[[losses]]]), 1) : 0)'), array('Kill-Loss', '###([[[kills]]] - [[[losses]]])', null, ' class="color"'), array('Kill-Win', '###([[[kills]]] - [[[wins]]])', null, ' class="color"'), array('Kill %', '###((0 != ([[[wins]]] + [[[losses]]])) ? perc([[[kills]]] / ([[[wins]]] + [[[losses]]]), 1) : 0)'), array('Last Online', '###ldate(Settings::read(\'long_date\'), strtotime(\'[[[last_online]]]\'))', null, ' class="date"')); $contents = get_table($table_format, $list, $table_meta); extract(Game::get_roll_stats()); // extracts $actual, $theor, and $values arrays // we can't use the table creator for this one, just build it by hand $contents .= ' <table class="dicetable"> <caption>Dice Percentages</caption> <thead> <tr> <th colspan="2" rowspan="2"> </th> <th colspan="1" rowspan="2">Outcome</th> <th colspan="3" rowspan="1">Attack</th> </tr>
\t\t\t<input type="hidden" name="token" value="{$_SESSION['token']}" /> \t\t\t<input type="hidden" name="game_id" value="{$_GET['id']}" /> \t\t\t<input type="hidden" name="player_id" value="{$_SESSION['player_id']}" /> \t\t\t<ul> \t\t\t\t<li><input type="submit" name="start" value="Start Game" /></li> \t\t\t</ul> \t\t</div></form> EOT; } // invitation form // grab our current player id list $players_joined = array_keys($game_players); // grab the full list of players $players_full = GamePlayer::get_list(); $invite_players = array_shrink($players_full, 'player_id'); // grab the players who's max game count has been reached $players_maxed = GamePlayer::get_maxed(); // grab the players who have opted out of the invite list $players_opt_out = GamePlayer::get_opt_out(); // remove the joined and maxed players from the invite list $players = array_diff($invite_players, array_merge($players_joined, $players_maxed, $players_opt_out)); // create the form $invitation_form = ' <form action="' . $_SERVER['REQUEST_URI'] . '" method="post"><div class="formdiv"> <p>Invite other players to this game:</p> <input type="hidden" name="token" value="' . $_SESSION['token'] . '" /> <input type="hidden" name="game_id" value="' . $_GET['id'] . '" /> <div><label for="player_ids">Players</label><select name="player_ids[]" id="player_ids" multiple="multiple" size="5">'; foreach ($players_full as $player) {