private function parseOptions(array &$data) { $viewData = array(); foreach ($this->possibleStartRegions as $id_option_type => $option_types) { $optionType = ModelOptionType::getOptionType($id_option_type); foreach ($option_types as $option_number => $options) { $optionViewData = array(); $optionViewData['number'] = $option_number; $optionViewData['countrySelectUnitCount'] = $optionType->getUnits(); $optionViewData['countrySelectCount'] = $optionType->getCountries(); $optionViewData['areas'] = array(); foreach ($options as $id_area => $startRegion) { // get area infos $areaModel = ModelArea::getArea($id_area); $area = array(); $area['id_area'] = $id_area; $area['number'] = $areaModel->getNumber(); $area['name'] = $areaModel->getName(); // check if country already selected $gameArea = ModelGameArea::getGameAreaForArea(ModelGame::getCurrentGame()->getId(), $id_area); $id_zarea = $gameArea->getId(); $modelMove = ModelSelectStartMove::getSelectStartMoveForUser(ModelUser::getCurrentUser()->getId(), ModelGame::getCurrentGame()->getId()); if ($modelMove->checkIfAreaIsSelected($option_number, $id_zarea)) { $area['checked'] = true; } $optionViewData['areas'][] = $area; } $viewData[] = $optionViewData; } } $data['options'] = $viewData; }
private function showMoves(array &$data) { // add unit description $units = ModelLandUnit::iterator(); $unitsViewData = array(); while ($units->hasNext()) { /* @var $unit ModelLandUnit */ $unit = $units->next(); $unitsViewData[] = array('id' => $unit->getId(), 'abbreviation' => $unit->getAbbreviation(), 'name' => $unit->getName()); } $data['units'] = $unitsViewData; // show moves $game = ModelGame::getCurrentGame(); $id_game = $game->getId(); $round = $game->getRound(); $phase = $game->getIdPhase(); if ($phase > PHASE_LANDMOVE) { ++$round; } $moves = ModelLandMove::iterator(ModelUser::getCurrentUser()->getId(), $id_game, $round); $movesViewData = array(); while ($moves->hasNext()) { /* @var $move ModelLandMove */ $move = $moves->next(); $moveViewData = array(); $moveViewData['id'] = $move->getIdMove(); $steps = $move->getSteps(); $zArea = ModelGameArea::getGameArea((int) $id_game, (int) array_shift($steps)); $area = ModelArea::getArea((int) $zArea->getIdArea()); $moveViewData['startArea'] = array('number' => $area->getNumber(), 'name' => $area->getName()); $zArea = ModelGameArea::getGameArea((int) $id_game, (int) array_pop($steps)); $area = ModelArea::getArea($zArea->getIdArea()); $moveViewData['destinationArea'] = array('number' => $area->getNumber(), 'name' => $area->getName()); $units = $move->getUnits(); $unit_iter = ModelLandUnit::iterator(); $unitsViewData = array(); while ($unit_iter->hasNext()) { /* @var $unit ModelLandUnit */ $unit = $unit_iter->next(); $id_unit = (int) $unit->getId(); $unitsViewData[] = array('id' => $id_unit, 'count' => isset($units[$id_unit]) ? $units[$id_unit] : 0); } $moveViewData['units'] = $unitsViewData; $movesViewData[] = $moveViewData; } $data['moves'] = $movesViewData; }
/** * @return array(int $id_adjacent_area) */ public function getAdjecents() { $area = ModelArea::getArea($this->id_area); return $area->getAdjecents(); }
private function showMoves(array &$data) { // show moves $costsSum = 0; $game = ModelGame::getCurrentGame(); $id_game = $game->getId(); $round = $game->getRound(); $phase = $game->getIdPhase(); if ($phase > PHASE_PRODUCTION) { ++$round; } $moves = ModelProductionMove::iterator(ModelUser::getCurrentUser()->getId(), $id_game, $round); $movesViewData = array(); while ($moves->hasNext()) { /* @var $move ModelProductionMove */ $move = $moves->next(); $moveViewData = array(); $moveViewData['id'] = $move->getIdMove(); $id_zarea = $move->getIdZArea(); $zArea = ModelGameArea::getGameArea((int) $id_game, $id_zarea); $area = ModelArea::getArea((int) $zArea->getIdArea()); $moveViewData['area'] = array('number' => $area->getNumber(), 'name' => $area->getName()); $units = $move->getUnits(); $unit_iter = ModelLandUnit::iterator(); $unitsViewData = array(); while ($unit_iter->hasNext()) { /* @var $unit ModelLandUnit */ $unit = $unit_iter->next(); $id_unit = (int) $unit->getId(); if (!isset($units[$id_unit]) || $units[$id_unit] <= 0) { continue; } $unitsViewData['name'] = $unit->getName(); $unitsViewData['count'] = $units[$id_unit]; $unitsViewData['cost'] = (int) $unit->getPrice() * $units[$id_unit]; $costsSum += $unitsViewData['cost']; break; } $moveViewData['units'] = $unitsViewData; $movesViewData[] = $moveViewData; } $data['moves'] = $movesViewData; $data['costsSum'] = $costsSum; }