Exemplo n.º 1
0
 protected function check()
 {
     if ($this->game && $this->game['status'] != Game::GAME_STATUS_ENDED) {
         $players = $this->players;
         if (count($players) >= Game::MINIMUM_PLAYERS_COUNT) {
             if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED) {
                 $this->check = self::ALREADY_INITIALIZED;
             } elseif ($this->game['status'] == Game::GAME_STATUS_STARTED) {
                 $this->check = self::ALREADY_STARTED;
             } else {
                 // TODO pocet charakterov ktore si useri mozu vyberat budu sucastou nastavenia miestnosti
                 if (is_numeric($this->params[0])) {
                     $characterRepository = new CharacterRepository();
                     $charactersCount = $characterRepository->getCountByValid(1);
                     if ($charactersCount < count($players) * $this->params[0]) {
                         $this->check = self::NOT_ENOUGH_CHARACTERS;
                     } else {
                         $this->check = self::OK;
                     }
                 } else {
                     $this->check = self::OK;
                 }
             }
         } else {
             $this->check = self::NOT_ENOUGH_PLAYERS;
         }
     } else {
         $this->check = self::NO_GAME;
     }
 }