public function run(array &$data) { $data['template'] = $this->getTemplate(); $this->addCurrentGameInfo($data); // get Model Data /** @var $iig ModelIsInGameInfo */ $iig = ModelIsInGameInfo::getIsInGameInfo(ModelUser::getCurrentUser()->getId(), ModelGame::getCurrentGame()->getId()); $this->id_set = $iig->getIdStartingSet(); $this->possibleStartRegions = ModelStartRegion::getRegionsForSet($this->id_set); // array(int id_opttype => array(int option_number => array(int id_area => ModelStartRegion))) // update moves if (isset($_POST['selectstart'])) { $this->selectOption($data); } if (isset($_POST['fixate_start'])) { $this->fixateMove($data); } // parse moves $this->checkFixate($data, PHASE_SELECTSTART); $this->checkCurrentPhase($data, PHASE_SELECTSTART); $this->parseOptions($data); }
/** * fixates the move if no error occured * * @throws ControllerException * @return void */ public function finishMove() { if ($this->error) { return; } // check if every option has taken countries $move = ModelSelectStartMove::getSelectStartMoveForUser($this->id_user, $this->id_game); $regions_selected = $move->getRegions(); // array(int option_number => array(int id_zarea)) // get Model Data /** @var $iig ModelIsInGameInfo */ $iig = ModelIsInGameInfo::getIsInGameInfo($this->id_user, $this->id_game); $id_set = $iig->getIdStartingSet(); $regions = ModelStartRegion::getRegionsForSet($id_set); // array(int id_opttype => array(int option_number => array(int id_area => ModelStartRegion))) foreach ($regions as $opttype) { foreach ($opttype as $opt_number => $areas) { if (!isset($regions_selected[$opt_number])) { throw new ControllerException('Choose countries first.'); } } } $this->fixatePhase(true); }