Esempio n. 1
0
 /**
  * test player
  * @return [type] [description]
  */
 public function testPlayer()
 {
     $player = new GamePlayer('hongker');
     $player->login('xxxxx');
     $player->killBoss();
     $player->upgrade();
 }
Esempio n. 2
0
        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 .= '
			<option value="' . $player['player_id'] . '">' . $player['username'] . '</option>';
    }
}
$groups = array('Normal' => array(0, 0), 'Eye of Horus' => array(0, 1), 'Sphynx' => array(1, 0), 'Sphynx & Horus' => array(1, 1));
Esempio n. 3
0
        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 .= '
Esempio n. 4
0
<?php

define('LOGIN', false);
require_once 'includes/inc.global.php';
// if we have a player_id in session, log them in, and check for admin
if (!empty($_SESSION['player_id'])) {
    $GLOBALS['Player'] = new GamePlayer();
    // this will redirect to login if failed
    $GLOBALS['Player']->log_in();
}
$no_new_users = false == Settings::read('new_users');
$max_users_set = 0 != Settings::read('max_users');
$max_users_reached = GamePlayer::get_count() >= Settings::read('max_users');
$not_admin = empty($GLOBALS['Player']) || !$GLOBALS['Player']->is_admin;
if ($not_admin && ($no_new_users || $max_users_set && $max_users_reached)) {
    Flash::store('Sorry, but we are not accepting new registrations at this time.');
}
if ($not_admin && isset($_SESSION['player_id'])) {
    $GLOBALS['Player'] = array();
    $_SESSION['player_id'] = false;
    unset($_SESSION['player_id']);
    unset($GLOBALS['Player']);
}
if (isset($_POST['register'])) {
    test_token();
    // die spammers
    if ('' != $_POST['website']) {
        header('Location: http://www.searchbliss.com/spambot/spambot-stopper.asp');
        exit;
    }
    try {
Esempio n. 5
0
/** function get_footer
 *		Generate the HTML footer portion of the page
 *
 * @param array option meta info
 * @return string HTML footer for page
 */
function get_footer($meta = array())
{
    $foot_data = isset($meta['foot_data']) ? $meta['foot_data'] : '';
    $players = GamePlayer::get_count();
    list($cur_games, $total_games) = Game::get_count();
    $Mysql = Mysql::get_instance();
    $html = '
	<div id="footerspacer">&nbsp;</div>
	<footer>
		<span>Total Players - ' . $players . '</span>
		<span>Active Games - ' . $cur_games . '</span>
		<span>Games Played - ' . $total_games . '</span>
	</footer>

	' . $foot_data . '

	<!-- Queries = ' . $Mysql->query_count . ' -->
</body>
</html>';
    return $html;
}
Esempio n. 6
0
				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">&nbsp;</th>
			<th colspan="1" rowspan="2">Outcome</th>
			<th colspan="3" rowspan="1">Attack</th>
		</tr>
Esempio n. 7
0
				<p>Warning! Javascript must be enabled for proper operation of <?php 
echo GAME_NAME;
?>
.</p>
			</noscript>

			<form method="post" action="index.php<?php 
echo $GLOBALS['_?_DEBUG_QUERY'];
?>
"><div class="formdiv">
				<div><label for="username">Username</label><input type="text" id="username" name="username" size="15" maxlength="20" tabindex="1" /></div>
				<div><label for="password">Password</label><input type="password" id="password" name="password" class="inputbox" size="15" tabindex="2" /></div>
				<label for="remember" class="inline"><input type="checkbox" id="remember" name="remember" checked="checked" tabindex="3" />Remember me</label><br />
				<input type="submit" name="login" value="Log in" tabindex="4" />
				<?php 
if (true == $new_users && (0 == $max_users || GamePlayer::get_count() < $max_users)) {
    ?>
<input type="button" value="Register" onclick="window.open('register.php<?php 
    echo $GLOBALS['_?_DEBUG_QUERY'];
    ?>
', '_self')" tabindex="5" /><?php 
}
?>
			</div></form>

			<noscript class="notice ctr">
				<p>Warning! Javascript must be enabled for proper operation of <?php 
echo GAME_NAME;
?>
.</p>
			</noscript>
Esempio n. 8
0
 private function history()
 {
     $current = new GamePlayer($this->getGameId(), $this->getTeamId(), $this->getPlayerId(), $this->getGoalieYN(), $this->getGamePlayerId());
     $current->build();
     db_insert('game_player_history')->fields(array('game_playerid' => $current->getGamePlayerId(), 'gameid' => $current->getGameId(), 'playerid' => $current->getPlayerId(), 'teamid' => $current->getTeamId(), 'goalie_yn' => $current->getGoalieYN(), 'saved_userid' => $current->getSavedUserID(), 'saved_datetime' => $current->getSavedDateTime(), 'history_userid' => $this->getSavedUserID(), 'history_datetime' => $this->getSavedDateTime()))->execute();
 }
Esempio n. 9
0
<?php

require_once 'includes/inc.global.php';
// this has nothing to do with creating a game
// but I'm running it here to prevent long load
// times on other pages where it would be ran more often
GamePlayer::delete_inactive(Settings::read('expire_users'));
Game::delete_inactive(Settings::read('expire_games'));
Game::delete_finished(Settings::read('expire_finished_games'));
$Game = new Game();
if (isset($_POST['create'])) {
    // 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 !');
    }
    test_token();
    try {
        $game_id = $Game->create();
        Flash::store('Game Created Successfully');
    } catch (MyException $e) {
        Flash::store('Game Creation FAILED !', false);
    }
}
$color_selection = '';
foreach ($Game->get_avail_colors() as $color) {
    $color_selection .= '<option class="' . strtolower(substr($color, 0, 3)) . '">' . ucfirst($color) . '</option>';
}
$meta['title'] = 'Create Game';
$meta['head_data'] = '
	<script type="text/javascript" src="scripts/create.js"></script>
';
Esempio n. 10
0
 /** 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;
 }
Esempio n. 11
0
\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) {
        if (in_array($player['player_id'], $players)) {
            $invitation_form .= '
				<option value="' . $player['player_id'] . '">' . $player['username'] . '</option>';
        }
    }
 public function __construct()
 {
     parent::__construct();
     $this->load->model('Game/GameBatterRepository', '_gamebatter');
 }