protected function addCurrentGameInfo(array &$data) { // parse game $gameModel = ModelGame::getCurrentGame(); $game = array(); $game['name'] = $gameModel->getName(); $game['round'] = $gameModel->getRound(); $game['phase'] = ModelPhase::getPhase($gameModel->getIdPhase())->getName(); $data['currentGame'] = $game; }
/** * sets the game phase (and if necessary also changes the status) * * @param int $id_phase * @return void * @throws NullPointerException */ public function setPhase($id_phase) { $id_phase = intval($id_phase); if ($this->id_phase === $id_phase) { return; } ModelPhase::getPhase($id_phase); $query = 'set_game_phase'; $dict = array(); $dict[':id_game'] = $this->id; $dict[':id_phase'] = $id_phase; DataSource::Singleton()->epp($query, $dict); $this->id_phase = $id_phase; if ($this->status === GAME_STATUS_DONE) { return; } if ($this->id_phase < PHASE_GAME_START) { $this->setStatus(GAME_STATUS_RUNNING); } else { if ($this->id_phase === PHASE_GAME_START) { $this->setStatus(GAME_STATUS_NEW); } else { if ($this->id_phase > PHASE_GAME_START) { $this->setStatus(GAME_STATUS_STARTED); } } } }