public function run(array &$data)
 {
     $data['template'] = $this->getTemplate();
     $this->addCurrentGameInfo($data);
     // parse user infos
     $users = array();
     $iter = ModelIsInGameInfo::iterator(null, ModelGame::getCurrentGame()->getId());
     while ($iter->hasNext()) {
         $ingame = $iter->next();
         $user = $this->getUserInfo($ingame);
         $users[] = $user;
     }
     $data['users'] = $users;
 }
 public static function parseCurrentUser(array &$data)
 {
     $user = ModelUser::getCurrentUser()->getViewData();
     $currGame = ModelGame::getCurrentGame();
     $user['games'] = array();
     $iter = ModelIsInGameInfo::iterator(ModelUser::getCurrentUser()->getId());
     while ($iter->hasNext()) {
         $gameModel = ModelGame::getGame($iter->next()->getIdGame());
         if ($gameModel->getStatus() !== GAME_STATUS_STARTED && $gameModel->getStatus() !== GAME_STATUS_RUNNING) {
             continue;
         }
         $game = array('id' => $gameModel->getId(), 'name' => $gameModel->getName());
         if ($currGame !== null && $currGame === $gameModel) {
             $game['selected'] = true;
         }
         $user['games'][] = $game;
     }
     if ($currGame === null) {
         $user['noGameSelected'] = true;
     } else {
         $user['currGame'] = $currGame->getViewData();
     }
     $data['user'] = $user;
 }
Example #3
0
 /**
  * @return int
  */
 public function getNumberOfPlayers()
 {
     $iter = ModelIsInGameInfo::iterator(null, $this->id);
     return $iter->size();
 }