Esempio n. 1
0
 /**
  * @param int $id
  * @return App\GameModule\DTO\Village
  */
 public function getVillage($id)
 {
     /** @var \stdClass $VData */
     $VData = $this->VDataModel->getByWId($id);
     $village = new App\GameModule\DTO\Village();
     $village->setId($id);
     if ($VData) {
         /** @var \stdClass $owner */
         $owner = $this->userModel->get($VData->owner);
         $village->setOwner($owner);
         $village->setActualWood($VData->wood);
         $village->setActualClay($VData->clay);
         $village->setActualIron($VData->iron);
         $village->setActualCrop($VData->crop);
         $village->setStorage($VData->maxstore);
         $village->setGranary($VData->maxcrop);
         $upkeep = $VData->pop + $this->upkeepService->getUpkeep($id);
         $village->setUpkeep($upkeep);
         $village->setName($VData->name);
         $village->setLoyalty($VData->loyalty);
         $village->setCapital($VData->capital);
         $village->setType($VData->type);
         $village->setNatar($VData->natar);
         $village->setCulturePoints($VData->cp);
         $village->setPopulation($VData->pop);
         $FData = $this->FDataModel->getByVref($village->getId())->toArray();
         $village->setFData($FData);
         $village->setProductionWood($this->productionService->getProductionWood($village));
         $village->setProductionClay($this->productionService->getProductionClay($village));
         $village->setProductionIron($this->productionService->getProductionIron($village));
         $village->setProductionCrop($this->productionService->getProductionCrop($village));
         $village->setMaxUpkeep($this->productionService->getBaseProductionCrop($village));
     }
     return $village;
 }
Esempio n. 2
0
 /**
  * @param App\GameModule\DTO\Village $village
  * @return float
  */
 public function getProductionCrop($village)
 {
     $production = $this->getBaseProductionCrop($village);
     // Step 7 subtract population
     $production = $production - $village->getPopulation();
     // Step 8 subtract troops
     $production = $production - $this->upkeepService->getUpkeep($village->getId());
     return round($production);
 }