本文整理汇总了PHP中Game::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::get方法的具体用法?PHP Game::get怎么用?PHP Game::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroupedGames
public function getGroupedGames()
{
// show all if in draft mode
$mode = Versioned::get_reading_mode();
if ($mode == 'Stage.Stage') {
$items = GroupedList::create(Game::get()->filter(array('ParentID' => $this->getCurrentEvent()->ID))->sort('Session'));
} else {
$items = GroupedList::create(Game::get()->filter(array('ParentID' => $this->getCurrentEvent()->ID, 'Status' => true))->sort('Session'));
}
return $items;
}
示例2: getAllTags
public function getAllTags($current = false)
{
if ($current) {
$games = $this->getCurrentGames();
} else {
$games = Game::get();
}
$list = array();
$result = new ArrayList();
foreach ($games as $game) {
$tags = $game->getGenresArray();
for ($i = 0; $i < count($tags); $i++) {
$list[$tags[$i]] = $tags[$i];
}
}
asort($list);
foreach ($list as $item) {
$result->push(new ArrayData(array('Title' => $item)));
}
return $result;
}
示例3: addGame
/**
* Attempts to save a game
*
* @return Game|null
*/
protected function addGame($form)
{
$siteConfig = SiteConfig::current_site_config();
$member = Member::currentUser();
$params = $this->request->allParams();
$fields = $form->Fields();
$id = $fields->dataFieldByName('ID')->Value();
$game = Game::get()->byID($id);
if (!$game) {
$game = Game::create();
}
$form->saveInto($game);
$game->FacilitatorID = $game->FacilitatorID ? $game->FacilitatorID : $member->ID;
$game->ParentID = $siteConfig->CurrentEventID;
try {
$game->write();
} catch (ValidationException $e) {
$form->sessionMessage($e->getResult()->message(), 'bad');
return;
}
return $game;
}
示例4: joined_duel
public function joined_duel($id)
{
foreach ($this->joined_duels as $i => $duel) {
if ($duel->id == $id) {
return $duel;
}
}
$duel = Game::get($id);
if ($duel == null) {
return false;
}
$duel->type = 'joineduel';
$this->joined_duels[] = $duel;
return $duel;
}
示例5: addPlayerGame
/**
* Attempts to save a game
*
* @return Game|null
*/
protected function addPlayerGame($data, $form)
{
$fields = $form->Fields();
$event = $this->getCurrentEvent();
$currentID = $event->ID;
$prefNum = $event->PreferencesPerSession;
$regID = $data['RegistrationID'];
$reg = Registration::get()->byID($regID);
if (!$reg) {
return false;
}
// @todo - handle a proper 'change game' case
if ($reg->PlayerGames()->Count() > 0) {
foreach ($reg->PlayerGames() as $playerGame) {
$reg->PlayerGames()->removeByID($playerGame->ID);
$playerGame->delete();
}
}
$favouriteID = $data["FavouriteID"];
for ($session = 1; $session <= $event->NumberOfSessions; $session++) {
$notPlay = $data["NotPlaying_" . $session];
$games = Game::get()->filter(array('Session' => $session, 'ParentID' => $currentID, 'Status' => true));
// Alter prefnumber so it stops when it encounters "not Playing"
if ($notPlay != 0 && $notPlay < $prefNum) {
$prefNum = $notPlay;
}
// if first choice is to not play, don't create any games
if ($notPlay === 1) {
continue;
}
foreach ($games as $game) {
$gamePref = $data["GameID_" . $game->ID];
// only store games with a preference higher than our threshold
if ($gamePref > $prefNum || !isset($gamePref)) {
continue;
}
$playerGame = PlayerGame::create();
$form->saveInto($playerGame);
$playerGame->GameID = $game->ID;
$playerGame->ParentID = $regID;
$playerGame->Preference = $gamePref;
if ($favouriteID == $game->ID) {
$playerGame->Favourite = true;
}
try {
$playerGame->write();
} catch (ValidationException $e) {
$form->sessionMessage($e->getResult()->message(), 'bad');
return;
}
}
}
return $playerGame;
}
示例6: doAssignTeams
public function doAssignTeams($data, Form $form)
{
// assign teams to the game
$game = Game::get()->filter('ID', $data['GameID'])->first();
$teamsCount = $game->Teams()->count();
if ($teamsCount < 2) {
// add the teams
$game->Teams->add($data['TeamOne']);
$game->Teams->add($data['TeamTwo']);
}
$redirectLink = $this->Link() . '?success=1';
return $this->redirect($redirectLink);
}
示例7: getGroupedGames
public function getGroupedGames()
{
return GroupedList::create(Game::get()->filter(array('ParentID' => $this->getCurrentEvent()->ID, 'Status' => true))->sort('Session'));
}
示例8: index
/**
* Display a listing of games
*
* @return Response
*/
public function index()
{
$games['inProgress'] = Game::get();
$games['completed'] = Game::onlyTrashed()->get();
return View::make('games.index', compact('games'));
}