Exemplo n.º 1
0
 public function populateOasis()
 {
     $oases = $this->WDataModel->getAllOases();
     foreach ($oases as $oasis) {
         if ($oasis->oasistype < 4) {
             $high = 1;
         } elseif ($oasis->oasistype < 10) {
             $high = 2;
         } else {
             $high = 0;
         }
         $this->ODataModel->add(['wref' => $oasis->id, 'type' => $oasis->oasistype, 'wood' => 800, 'iron' => 800, 'clay' => 800, 'crop' => 800, 'maxstore' => 800, 'maxcrop' => 800, 'loyalty' => 100, 'owner' => App\FrontModule\Model\User\UserModel::NATURE_ID, 'name' => 'Unoccupied Oasis', 'high' => $high]);
         $this->saveOasisUnits($oasis->id, $oasis->oasistype);
     }
 }
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);
 }