Exemplo n.º 1
0
 /**
  * @param int $id
  * @param int $level
  * @param App\GameModule\DTO\Village|bool $village
  * @return App\GameModule\DTO\Building|bool
  */
 public function getBuilding($id, $level, $village = FALSE)
 {
     /** @var \stdClass $buildingData */
     $buildingData = $this->buildingModel->get($id);
     /** @var \stdClass $levelData */
     $levelData = $this->buildingModel->getBuildingLevel($id, $level);
     if ($levelData) {
         $building = new App\GameModule\DTO\Building();
         $building->setName($buildingData->name);
         $building->setDescription($buildingData->description);
         $building->setLevel($levelData->level);
         $building->setProduction($levelData->production * $this->speed);
         $building->setParameter($levelData->parameter);
         $building->setCulturePoints($levelData->culturepoints);
         $building->setBuilding($buildingData->id);
         $building->setWood($levelData->wood);
         $building->setClay($levelData->clay);
         $building->setIron($levelData->iron);
         $building->setCrop($levelData->crop);
         $building->setUpkeep($levelData->pop);
         $time = $levelData->time / $this->speed;
         if ($village) {
             $time = $time * $this->getMainBuildingSpeed($village);
         }
         $building->setTime(round($time));
     } else {
         $building = FALSE;
     }
     return $building;
 }
Exemplo n.º 2
0
 /**
  * @param App\GameModule\DTO\Village $village
  * @return int
  */
 public function getBaseProductionCrop($village)
 {
     $production = 0;
     $FData = $village->getFData();
     $grainMill = FALSE;
     $bakery = FALSE;
     $cropFields = [];
     // Step 1 find fields
     for ($i = 1; $i <= 38; $i++) {
         if ($FData['f' . $i . 't'] === App\GameModule\Model\Building\BuildingModel::CROPLAND) {
             $cropFields[] = $FData['f' . $i];
         }
         if ($FData['f' . $i . 't'] === App\GameModule\Model\Building\BuildingModel::GRAIN_MILL) {
             $grainMill = $FData['f' . $i];
         }
         if ($FData['f' . $i . 't'] === App\GameModule\Model\Building\BuildingModel::BAKERY) {
             $bakery = $FData['f' . $i];
         }
     }
     // Step 2 calculate raw production
     foreach ($cropFields as $level) {
         /** @var \stdClass $cropland */
         $cropland = $this->buildingModel->getBuildingLevel(4, $level);
         $production += $cropland->production;
     }
     // Step 3 apply oasis
     $production = $production * (1 + 0.25 * $this->ODataModel->countByUserVillage($village->getOwner()->id, $village->getId(), App\FrontModule\Model\OData\ODataModel::MODE_CROP) + 0.5 * $this->ODataModel->countByUserVillage($village->getOwner()->id, $village->getId(), App\FrontModule\Model\OData\ODataModel::MODE_CROP_BIG));
     // Step 4 apply grainMill and bakery
     if ($grainMill) {
         /** @var \stdClass $grainMill */
         $grainMill = $this->buildingModel->getBuildingLevel(App\GameModule\Model\Building\BuildingModel::GRAIN_MILL, $grainMill);
         $production = $production * ($grainMill->attribute / 100 + 1);
     }
     if ($bakery) {
         /** @var \stdClass $bakery */
         $bakery = $this->buildingModel->getBuildingLevel(App\GameModule\Model\Building\BuildingModel::BAKERY, $bakery);
         $production = $production * ($bakery->attribute / 100 + 1);
     }
     // Step 5 apply bonus production
     if ($village->getOwner()->b4 === 1) {
         $production = $production * 1.25;
     }
     // Step 6 apply speed
     $production = $production * $this->speed;
     return round($production);
 }