Example #1
0
 public function main()
 {
     $gameId = intval(Utils::post('game'));
     $roomId = intval(Utils::post('room'));
     $gameRepository = new GameRepository();
     // $gameRepository->addAdditionalWhere(array('column' => 'status', 'value' => Game::GAME_STATUS_ENDED, 'xxx' => '!='));
     $gameRepository->addOrderBy(array('id' => 'DESC'));
     $game = $gameRepository->getOneByRoom($roomId);
     //		if ($gameId) {
     //			$game = $gameRepository->getOneById($gameId);
     //		} else {
     //
     //		}
     $roomRepository = new RoomRepository();
     $room = $roomRepository->getOneById($roomId);
     $gameBox = new GameBox();
     $gameBox->setRoom($room);
     if ($game) {
         $gameBox->setGame($game);
     }
     echo $gameBox->render();
 }
Example #2
0
 public function getRoomObject()
 {
     $roomRepository = new RoomRepository();
     $room = $roomRepository->getOneById($this['room']);
     return $room;
 }
Example #3
0
 private function __construct($params, $localizedParams, $game)
 {
     $this->params = $params;
     $this->game = $game;
     $this->localizedParams = $localizedParams;
     $this->interTurnReason = unserialize($this->game['inter_turn_reason']);
     $attackingPlayerId = $this->interTurnReason['from'];
     $playerRepository = new PlayerRepository();
     $this->attackingPlayer = $playerRepository->getOneById($attackingPlayerId);
     $cardRepository = new CardRepository();
     $this->attackingCards = $cardRepository->getById($this->interTurnReason['cards']);
     $roomRepository = new RoomRepository();
     if ($game) {
         $room = $roomRepository->getOneById($game['room']);
     } else {
         $roomAlias = Utils::get('identifier');
         $room = $roomRepository->getOneByAlias($roomAlias);
     }
     $this->room = $room;
     if ($this->game) {
         $this->players = $this->game->getAdditionalField('players');
         $attackedPlayer = $this->params['enemyPlayerUsername'];
         foreach ($this->players as $player) {
             $user = $player->getUser();
             if ($user['username'] == $attackedPlayer) {
                 $this->attackedPlayer = $player;
                 break;
             }
         }
     }
 }