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; }
private function fill_member_vars() { $query = 'get_game_phase_info'; $dict = array(); $dict[':id_user'] = $this->id_user; $dict[':id_game'] = $this->id_game; $iter = ModelPhase::iterator(); while ($iter->hasNext()) { $id_phase = $iter->next()->getId(); $dict[':id_phase'] = $id_phase; $result = DataSource::getInstance()->epp($query, $dict); if (empty($result)) { $this->create_info($id_phase); } else { $this->notification_rules[$id_phase] = $result[0]['notif_rule'] ? true : false; $this->is_ready[$id_phase] = $result[0]['is_ready'] ? true : false; } } }
/** * 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); } } } }