本文整理汇总了PHP中Game::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::load方法的具体用法?PHP Game::load怎么用?PHP Game::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::load方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process()
{
$this->template_name = 'pages/slot/day.tpl';
list($year, $month, $day) = preg_split("/[\\/-]/", $_GET['date']);
$today = getdate();
$yyyy = is_numeric($year) ? $year : $today['year'];
$mm = is_numeric($month) ? $month : $today['mon'];
$dd = is_numeric($day) ? $day : $today['mday'];
if (!validate_date_input($yyyy, $mm, $dd)) {
error_exit('That date is not valid');
}
$this->smarty->assign('date', sprintf("%4d/%02d/%02d", $yyyy, $mm, $dd));
$formattedDay = strftime('%A %B %d %Y', mktime(6, 0, 0, $mm, $dd, $yyyy));
$this->title = "Field Availability Report » {$formattedDay}";
$sth = GameSlot::query(array('game_date' => sprintf('%d-%d-%d', $year, $month, $day), '_order' => 'g.game_start, field_code, field_num'));
$num_open = 0;
$slots = array();
while ($g = $sth->fetch()) {
// load game info, if game scheduled
if ($g['game_id']) {
$g['game'] = Game::load(array('game_id' => $g['game_id']));
} else {
$num_open++;
}
$slots[] = $g;
}
$this->smarty->assign('slots', $slots);
$this->smarty->assign('num_fields', count($slots));
$this->smarty->assign('num_open', $num_open);
return true;
}
示例2: __construct
function __construct($id)
{
$this->game = Game::load(array('game_id' => $id));
if (!$this->game) {
error_exit("That game does not exist");
}
game_add_to_menu($this->get_league(), $this->game);
}
示例3: byGame
public function byGame()
{
$CRs = new CR($this->db);
$this->f3->set('list', $CRs->byGame($this->f3->get('PARAMS.id')));
$Game = new Game($this->db);
$this->f3->set('game', $myGame = $Game->load(array('id=?', $this->f3->get('PARAMS.id'))));
$this->f3->set('site_title', 'CRs de ' . $myGame['name'] . ' | CROTYpedia');
$this->f3->set('view', 'cr/index.htm');
}
示例4: process
function process()
{
global $lr_session;
$this->title = "{$this->field->fullname} » Bookings";
$this->template_name = 'pages/field/bookings.tpl';
if ($this->field->status != 'open') {
error_exit("That field is closed");
}
$sth = GameSlot::query(array('fid' => $this->field->fid, '_extra' => 'DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND DATE_ADD(CURDATE(), INTERVAL 1 YEAR)', '_order' => 'g.game_date, g.game_start'));
$slots = array();
while ($slot = $sth->fetchObject('GameSlot')) {
if ($slot->game_id) {
$slot->game = Game::load(array('game_id' => $slot->game_id));
}
$slots[] = $slot;
}
$this->smarty->assign('slots', $slots);
return true;
}
示例5: APICrImport
public function APICrImport()
{
$postdata = file_get_contents("php://input");
$request = json_decode($postdata, true);
ob_start();
$this->APICrParseInternal($request);
$myStr = ob_get_contents();
ob_end_clean();
$cr = json_decode($myStr, true)['data'];
//print_r($request);
//print_r($cr);
//header("HTTP/1.1 406 Not Found");
//print_r($request);
// exit();
$GamesID = array();
$CRID = 0;
//On check les jeux
$games = new Game($this->db);
foreach ($request['games'] as $key => $value) {
// print_r($value);
//si ID == -1 = saisie manuelle
if ($value['id'] == -1) {
} else {
if (isset($value['origin']) && $value['origin'] == 'bdd') {
// origin = bdd
$games->load(array('id = ?', $value['id']));
} else {
$games->load(array('api_uid = ?', $value['id']));
}
}
if ($games->id) {
$GamesID[] = $games->id;
} else {
if ($value['id'] == -1) {
$value['id'] = 99999999;
}
//on doit l'ajouter
$games->reset();
$games->name = $value['name'];
$games->api_uid = $value['id'];
$games->api_image = $value['image']['super_url'];
$games->api_date = $value['date'];
$games->save();
$GamesID[] = $games->id;
}
$games->reset();
}
//print_r($GamesID);
//On ajoute le CR
$newCR = new CR($this->db);
//on vérfie si il est pas déjà en base
$newCR->load(array('hfr_post_id = ?', $cr['hfr_post_id']));
if ($newCR->id) {
header("HTTP/1.1 405 Not Found");
echo 'CR déjà en base :) > <a target="_blank" href="/crotypedia/' . $newCR->id . '">voir sur le site</a>';
exit;
}
$newCR->reset();
$crProcessed = $newCR->processRawContent($cr);
//print_r($crProcessed);
$newCR->hfr_cat_id = 5;
$newCR->hfr_subcat_id = 249;
$newCR->hfr_topic_id = 177180;
//$newCR->hfr_page_id = $crProcessed['hfr_page_id'];
$newCR->hfr_post_id = $crProcessed['hfr_post_id'];
$newCR->hfr_user_id = $crProcessed['hfr_user_id'];
$newCR->username = $crProcessed['username'];
$newCR->content = $crProcessed['content'];
$newCR->content_raw = $crProcessed['content_raw'];
$newCR->date_posted = $crProcessed['date_posted'];
$newCR->date_modified = date('Y-m-d H:i:s');
$newCR->date_added = date('Y-m-d H:i:s');
$newCR->active = 1;
$newCR->type_id = $request['type'];
$newCR->format_id = $request['format'];
$newCR->comment = $request['comment'];
$newCR->save();
$CRID = $newCR->id;
$newCR->reset();
//On ajoute en DB
$CrGame = new CrGame($this->db);
foreach ($GamesID as $gid) {
$CrGame->cr_id = $CRID;
$CrGame->game_id = $gid;
$CrGame->save();
$CrGame->reset();
}
echo 'CR ajouté > <a target="_blank" href="/crotypedia/' . $CRID . '">voir sur le site</a>';
}
示例6: session_start
<?php
session_start();
require_once '../class/Game.class.php';
header("Content-Type: application/json");
if (isset($_SESSION['party_id'])) {
$party = Game::load($_SESSION['party_id']);
$ships = array();
foreach ($party->getPlayers() as $player) {
foreach ($player->getShips() as $ship) {
$new = array();
$new['owner'] = $player->getColor();
$new['size'] = $ship->getSize();
$new['position'] = $ship->getPosition();
$new['name'] = $ship->getName();
$new['sprite'] = "styles/img/sprites/" . $ship->getSprite();
array_push($ships, $new);
}
}
echo json_encode($ships);
header("HTTP/1.0 200 OK");
} else {
header("HTTP/1.0 401 Unauthorized");
}
示例7: header
Game::newGame($_REQUEST["new"]);
}
if (require_params("reset_dungeon")) {
$game = Game::load();
$game->delete();
header("Location: /game");
die;
}
if (require_params("reset_messages")) {
$_SESSION["user"]->json_data["read_messages"] = array();
$_SESSION["user"]->save();
header("Location: /game");
die;
}
if (true) {
$game = Game::load();
?>
<h2><?php
echo $game->name;
?>
</h2>
<a href="?reset_dungeon=true">Reset dungeon</a>
<a href="?reset_messages=true">Reset read messages</a>
<div id="game-container" class="game-tile"></div>
<script type="text/javascript">
TLOR.setup($('#game-container'), <?php
echo json_encode($game);
?>
, {});
TLOR.play();
示例8: perform
function perform($edit)
{
global $dbh;
$dataInvalid = $this->isDataInvalid($edit['games']);
if ($dataInvalid) {
error_exit($dataInvalid);
}
$should_publish = $edit['published'] == 'yes' ? 1 : 0;
while (list($game_id, $game_info) = each($edit['games'])) {
$game = Game::load(array('game_id' => $game_id));
if (!$game) {
error_exit("Attempted to edit game info for a nonexistant game!");
}
if ($this->league->schedule_type == "roundrobin") {
$game->set('round', $game_info['round']);
}
$game->set('home_team', $game_info['home_id']);
$game->set('away_team', $game_info['away_id']);
// find the old slot id!
$old_slot_id = $game->slot_id;
$game->set('slot_id', $game_info['slot_id']);
$game->set('published', $should_publish);
if (!$game->save()) {
error_exit("Couldn't save game information!");
}
// there can be more gameslots than games, so it is important
// to clear out the old game slot!
// (if the old slot id is blank, it means that this game's slot has already been overwritten)
if ($old_slot_id && $old_slot_id != $game->slot_id) {
$sth = $dbh->prepare('UPDATE gameslot SET game_id = NULL WHERE slot_id = ?');
$sth->execute(array($old_slot_id));
}
}
return true;
}
示例9: process
function process()
{
global $lr_session, $dbh;
$this->title = $lr_session->attr_get('fullname');
$this->template_name = 'pages/home.tpl';
/* Handle display of RSS feed itmes, if enabled */
$feed_url = variable_get('rss_feed_url', null);
if ($feed_url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $feed_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
# Fetch RSS data
$xml = curl_exec($curl);
curl_close($curl);
if ($xml) {
$xmlObj = simplexml_load_string($xml);
$count = 0;
$limit = variable_get('rss_feed_items', 2);
$items = array();
foreach ($xmlObj->channel[0]->item as $item) {
$items[] = array('title' => $item->title, 'link' => $item->link);
if (++$count >= $limit) {
break;
}
}
if ($count > 0) {
$this->smarty->assign('rss_feed_title', variable_get('rss_feed_title', 'OCUA Volunteer Opportunities'));
$this->smarty->assign('rss_feed_items', $items);
}
}
}
/* Display teams */
$rosterPositions = Team::get_roster_positions();
$teams = array();
foreach ($lr_session->user->teams as $team) {
$team->rendered_position = $rosterPositions[$team->position];
$teams[] = $team;
}
reset($lr_session->user->teams);
$this->smarty->assign('teams', $teams);
/* Display leagues */
// TODO: For each league, need to display # of missing scores,
// pending scores, etc.
$this->smarty->assign('leagues', $lr_session->user->leagues);
/* Display recent and upcoming games */
$games = array();
// TODO: query should be moved to person object, or a helper in game.inc
$sth = $dbh->prepare('SELECT s.game_id, t.team_id, t.status FROM schedule s, gameslot g, teamroster t WHERE s.published AND ((s.home_team = t.team_id OR s.away_team = t.team_id) AND t.player_id = ?) AND g.game_id = s.game_id AND g.game_date < CURDATE() ORDER BY g.game_date desc, g.game_start desc LIMIT 4');
$sth->execute(array($lr_session->user->user_id));
while ($row = $sth->fetch(PDO::FETCH_OBJ)) {
$game = Game::load(array('game_id' => $row->game_id));
$game->user_team_id = $row->team_id;
$games[] = $game;
}
$games = array_reverse($games);
$sth = $dbh->prepare('SELECT s.game_id, t.team_id, t.status FROM schedule s, gameslot g, teamroster t WHERE s.published AND ((s.home_team = t.team_id OR s.away_team = t.team_id) AND t.player_id = ?) AND g.game_id = s.game_id AND g.game_date >= CURDATE() ORDER BY g.game_date asc, g.game_start asc LIMIT 4');
$sth->execute(array($lr_session->user->user_id));
while ($row = $sth->fetch(PDO::FETCH_OBJ)) {
$game = Game::load(array('game_id' => $row->game_id));
$game->user_team_id = $row->team_id;
$games[] = $game;
}
foreach ($games as $game) {
$score = '';
if ($game->is_finalized()) {
$score = "{$game->home_score} - {$game->away_score}";
} else {
/* Not finalized yet, so we will either:
* - display entered score if present
* - display score entry link if game date has passed
* - display a blank otherwise
*/
$entered = $game->get_score_entry($game->user_team_id);
if ($entered) {
// need to match entered score order to displayed team order!
if ($entered->team_id == $game->home_id) {
$score = "{$entered->score_for} - {$entered->score_against}";
} else {
$score = "{$entered->score_against} - {$entered->score_for}";
}
$score .= " (unofficial, waiting for opponent)";
$game->score_entered = $score;
} else {
if ($lr_session->has_permission('game', 'submit score', $game) && $game->timestamp < time()) {
$game->user_can_submit = true;
}
}
}
}
$this->smarty->assign('games', $games);
return;
}
示例10: finalize_old_games
/**
* Finalize any games considered 'old'.
*/
function finalize_old_games()
{
global $CONFIG, $dbh;
if ($this->finalize_after == 0) {
return '';
}
$output = '';
// TODO: Game::load_many()? Or at least Game::query()?
$sth = $dbh->prepare("SELECT\n\t\t\t\tDISTINCT s.game_id,\n\t\t\t\t(UNIX_TIMESTAMP(CONCAT(g.game_date, ' ', g.game_start)) + ?) AS start_timestamp\n\t\t\tFROM\n\t\t\t\tschedule s,\n\t\t\t\tgameslot g\n\t\t\tWHERE\n\t\t\t\ts.league_id = ?\n\t\t\tAND\n\t\t\t\tg.game_id = s.game_id\n\t\t\tAND\n\t\t\t\t(UNIX_TIMESTAMP(CONCAT(g.game_date, ' ', g.game_start)) + ?) < UNIX_TIMESTAMP(NOW())\n\t\t\tAND\n\t\t\t\t(ISNULL(s.home_score) OR ISNULL(s.away_score))\n\t\t\tORDER BY\n\t\t\t\tg.game_id");
$local_adjust_secs = $CONFIG['localization']['tz_adjust'] * 60;
$sth->execute(array($local_adjust_secs, $this->league_id, $local_adjust_secs + $this->finalize_after * 60 * 60));
while ($game_id = $sth->fetchColumn()) {
$game = Game::load(array('game_id' => $game_id));
if ($game->finalize()) {
$stat = 'Finalized';
} else {
$stat = 'DID NOT finalize';
}
$output .= "<p>{$stat} {$game->game_date}-{$game->game_start} game " . l($game_id, "game/edit/{$game_id}") . ' between ' . l($game->home_name, "team/view/{$game->home_team}") . ' and ' . l($game->away_name, "team/view/{$game->away_team}") . ", status {$game->status}</p>";
}
return $output;
}
示例11: process
function process()
{
global $dbh;
$this->template_name = 'pages/league/slots.tpl';
list($year, $month, $day) = preg_split("/[\\/-]/", $_GET['date']);
$today = getdate();
$yyyy = is_numeric($year) ? $year : $today['year'];
$mm = is_numeric($month) ? $month : $today['mon'];
$dd = is_numeric($day) ? $day : $today['mday'];
if (!validate_date_input($yyyy, $mm, $dd)) {
error_exit('That date is not valid');
}
$this->smarty->assign('date', sprintf("%4d/%02d/%02d", $yyyy, $mm, $dd));
$formattedDay = strftime('%A %B %d %Y', mktime(6, 0, 0, $mm, $dd, $yyyy));
$this->title = "Field Availability Report » {$this->league->fullname} » {$formattedDay}";
$sth = $dbh->prepare('SELECT
g.slot_id,
COALESCE(f.code, pf.code) AS field_code,
COALESCE(f.num, pf.num) AS field_num,
COALESCE(f.region, pf.region) AS field_region,
g.fid,
frh.rank AS home_site_rank,
fra.rank AS away_site_rank,
g.game_id
FROM
league_gameslot_availability l,
gameslot g
LEFT JOIN schedule s ON (g.game_id = s.game_id)
LEFT JOIN team t ON (s.home_team = t.team_id)
LEFT JOIN field_ranking_stats frh ON (s.game_id = frh.game_id AND frh.team_id = s.home_team)
LEFT JOIN field_ranking_stats fra ON (s.game_id = fra.game_id AND fra.team_id = s.away_team),
field f LEFT JOIN field pf ON (f.parent_fid = pf.fid)
WHERE l.league_id = ?
AND g.game_date = ?
AND g.slot_id = l.slot_id
AND f.fid = g.fid
ORDER BY field_code, field_num');
$sth->execute(array($this->league->league_id, sprintf('%d-%d-%d', $year, $month, $day)));
$num_open = 0;
$slots = array();
while ($g = $sth->fetch()) {
// load game info, if game scheduled
if ($g['game_id']) {
$g['game'] = Game::load(array('game_id' => $g['game_id']));
} else {
$num_open++;
}
$slots[] = $g;
}
$allDays = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
$day_indexes = array();
$league_days = explode(',', $this->league->day);
foreach ($league_days as $day) {
$day_indexes[] = $allDays[strtolower($day)];
}
$this->smarty->assign('league_days', implode(',', $day_indexes));
$this->smarty->assign('slots', $slots);
$this->smarty->assign('num_fields', count($slots));
$this->smarty->assign('num_open', $num_open);
return true;
}