コード例 #1
0
ファイル: RefreshGame.php プロジェクト: Tomeno/lulcobang
 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();
 }
コード例 #2
0
ファイル: Game.php プロジェクト: Tomeno/lulcobang
 public function getRoomObject()
 {
     $roomRepository = new RoomRepository();
     $room = $roomRepository->getOneById($this['room']);
     return $room;
 }
コード例 #3
0
ファイル: Command.php プロジェクト: Tomeno/lulcobang
 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;
             }
         }
     }
 }