public function attached($presenter) { parent::attached($presenter); $this->template->current = $this->presenter->template->current; $this->template->next = $this->presenter->template->next; $this->village = $this->villageService->getVillage($this->presenter->getParameter('id')); $building = $this->presenter->getParameter('building'); switch ($building) { case App\GameModule\Model\Building\BuildingModel::WOODCUTTER: case App\GameModule\Model\Building\BuildingModel::CLAY_PIT: case App\GameModule\Model\Building\BuildingModel::IRON_MINE: case App\GameModule\Model\Building\BuildingModel::CROPLAND: $this->renderResourceField(); break; case App\GameModule\Model\Building\BuildingModel::WAREHOUSE: case App\GameModule\Model\Building\BuildingModel::CRANNY: case App\GameModule\Model\Building\BuildingModel::GRANARY: case App\GameModule\Model\Building\BuildingModel::TRAPPER: $this->renderCapacity(); break; case App\GameModule\Model\Building\BuildingModel::MAIN_BUILDING: $this->renderMainBuilding(); break; case App\GameModule\Model\Building\BuildingModel::BARRACKS: $this->renderBarracks(); break; case App\GameModule\Model\Building\BuildingModel::STABLE: $this->renderStable(); break; case App\GameModule\Model\Building\BuildingModel::ACADEMY: $this->renderAcademy(); break; case App\GameModule\Model\Building\BuildingModel::ARMOURY: $this->renderArmoury(); break; case App\GameModule\Model\Building\BuildingModel::BLACKSMITH: $this->renderBlacksmith(); break; case App\GameModule\Model\Building\BuildingModel::MARKET_PLACE: $this->renderMarketPlace(); break; case App\GameModule\Model\Building\BuildingModel::EMBASSY: $this->renderEmbassy(); break; case App\GameModule\Model\Building\BuildingModel::HERO_MANSION: $this->renderHeroMansion(); break; case App\GameModule\Model\Building\BuildingModel::RALLY_POINT: $this->renderRallyPoint(); break; default: $this->template->setFile(__DIR__ . '/Template/Blank.latte'); break; } }
public function actionDefault($id, $destination) { $this->village; /** @var \stdClass $wdata */ $wdata = $this->WDataModel->get($id); if ($wdata->occupied) { $destinationVillage = $this->villageService->getVillage($destination); } else { $destinationVillage = FALSE; } }
public function renderChooseBuilding($id, $field) { $this->template->village = $village = $this->villageService->getVillage($id); $available = $this->buildingAvailability->getAvailable($village, $field); $availableData = []; foreach ($available as $building) { $availableData[] = ['building' => $building, 'canBuild' => $this->buildingService->canBuild($building, $field, $village), 'busyWorkers' => $this->buildingService->busyWorkers($building, $village), 'storage' => $this->buildingService->isStorageBigEnough($building, $village), 'granary' => $this->buildingService->isGranaryBigEnough($building, $village), 'resources' => $this->buildingService->isThereEnoughResources($building, $village), 'buldingStatus' => $this->buildingService->canBuildLevel($building, $field, $village)]; } $this->template->available = $availableData; $this->template->field = $field; }
public function actionDefault($id) { if (!$id) { /** @var \stdClass $field */ $field = $this->VDataModel->getByUser($this->presenter->user->getId()); $id = $field->wref; } $this->template->village = $this->villageService->getVillage($id); $this->template->units = $this->unitsModel->get($id); $this->template->unitNames = $this->unitService->getNames(); }
public function render() { $id = $this->presenter->getParameter('id'); if (!$id) { /** @var \stdClass $field */ $field = $this->VDataModel->getByUser($this->presenter->user->getId()); $id = $field->wref; } $this->template->village = $this->villageService->getVillage($id); $this->template->setFile(__DIR__ . '/ResourceControl.latte'); $this->template->render(); }
public function process() { if (!$this->isLocked()) { $time = $this->dateTimeProvider->getDateTime()->format('U'); $ids = $this->VDataModel->getAllIds(); foreach ($ids as $id) { $village = $this->villageService->getVillage($id); $this->productionService->processProduction($village, $time); } $this->buildingService->processBuildings($time); $this->processTraining->process($time); $this->releaseLock(); } }
public function actionDefault($id) { if (!$id) { /** @var \stdClass $field */ $field = $this->VDataModel->getByUser($this->presenter->user->getId()); $id = $field->wref; } $this->template->village = $village = $this->villageService->getVillage($id); $this->template->names = $this->buildingModel->getAll(); if ($village->getOwner()->tribe === 1) { $wallId = 31; } elseif ($village->getOwner()->tribe === 2) { $wallId = 32; } else { $wallId = 33; } $this->template->wallId = $wallId; $this->template->wallLevel = $village->getFData()['f' . $wallId]; }
/** * Handle all related to create new user. * * @param \stdClass $data */ public function createUser($data) { $user = $this->registerUser($data); /** @var \stdClass $field */ $field = $this->WDataModel->getRandom($data->position); $this->WDataModel->setFieldTaken($field->id); $villageName = $this->villageService->getNewVillageName($user); $vid = $this->VDataModel->addVillageForUser($user, $field, $villageName); $this->FDataModel->addResourceFields($field->fieldtype, $vid); $this->unitsModel->add(['vref' => $vid]); $this->TDataModel->add(['vref' => $vid]); $this->ABDataModel->add(['vref' => $vid]); }
public function renderReview($form) { \Tracy\Debugger::barDump($form); \Tracy\Debugger::barDump($this->units); $this->template->data = $form->getValues(); if ($this->wdata->occupied) { $destination = $this->villageService->getVillage($this->wdata->id); } else { $destination = FALSE; } $this->template->destination = $destination; $this->template->wdata = $this->wdata; $this->template->setFile(__DIR__ . '/ReviewUnits.latte'); }
/** * @param int $id * @param int $wid */ public function actionDetail($id, $wid) { $this->template->id = $id; $village = $this->villageService->getVillage($id); /** @var \stdClass $wdata */ $this->template->wdata = $wdata = $this->WDataModel->get($wid); $this->template->reports = $this->reportService->getLastReportsForUser($wid, $this->user->getId()); $this->template->rallyPoint = $this->buildingService->isBuilt($village, App\GameModule\Model\Building\BuildingModel::RALLY_POINT); if ($wdata->occupied === 1) { $this->template->village = $this->villageService->getVillage($wid); } else { $this->template->village = FALSE; } if ($wdata->oasistype != 0 && $wdata->occupied == 0) { $this->template->units = $this->unitsModel->get($wid); $this->template->unitNames = $this->unitService->getNames(); } else { $this->template->units = []; } }
public function build($id, $field, $building, $level) { $village = $this->villageService->getVillage($id); $next = $this->getBuilding($building, $level, $village); if ($this->isThereEnoughResources($next, $village)) { if ($village->getOwner()->tribe === 1) { if ($next->getBuilding() < 5) { if ($time = $this->BDataModel->getLastOuterBuildTime($village->getId())) { $time += $next->getTime(); } else { /** @var int $now */ $now = $this->dateTimeProvider->getDateTime()->format('U'); $time = $next->getTime() + $now; } } elseif ($next->getBuilding() > 4) { if ($time = $this->BDataModel->getLastInnerBuildTime($village->getId())) { $time += $next->getTime(); } else { /** @var int $now */ $now = $this->dateTimeProvider->getDateTime()->format('U'); $time = $next->getTime() + $now; } } else { /** @var int $now */ $now = $this->dateTimeProvider->getDateTime()->format('U'); $time = $next->getTime() + $now; } } else { if ($time = $this->BDataModel->getLastBuildTime($village->getId())) { $time += $next->getTime(); } else { /** @var int $now */ $now = $this->dateTimeProvider->getDateTime()->format('U'); $time = $next->getTime() + $now; } } $this->BDataModel->add(['wid' => $id, 'field' => $field, 'type' => $building, 'timestamp' => $time, 'level' => $level]); $this->VDataModel->update($id, ['wood' => $village->getActualWood() - $next->getWood(), 'clay' => $village->getActualClay() - $next->getClay(), 'iron' => $village->getActualIron() - $next->getIron(), 'crop' => $village->getActualCrop() - $next->getCrop(), 'lastupdate2' => $this->dateTimeProvider->getDateTime()->format('U')]); } }