예제 #1
0
 public function calculateBaseCapacity(Base $base)
 {
     $buildingCounters = $base->getBuildingCounters();
     $shelters = $this->buildingFinder->getByGroup('shelters');
     $baseCapacity = new Resources();
     foreach ($shelters as $id => $shelter) {
         $counter = $buildingCounters[$id];
         /* @var $shelter \frontend\behaviors\ShelterCapacityBehavior */
         $capacity = $shelter->calculateShelterCapacity($counter);
         $baseCapacity->chemicals += $capacity->chemicals;
         $baseCapacity->energy += $capacity->energy;
         $baseCapacity->ice += $capacity->ice;
         $baseCapacity->iron += $capacity->iron;
         $baseCapacity->population += $capacity->population;
         $baseCapacity->steel += $capacity->steel;
         $baseCapacity->vv4a += $capacity->vv4a;
         $baseCapacity->water += $capacity->water;
     }
     return $baseCapacity;
 }
예제 #2
0
 private function calculateResidentialsSpace()
 {
     // TODO initial population space provided by the colony headquarters?
     $populationSpace = 150;
     $buildingCounters = $this->base->getBuildingCounters();
     $residentialBuildings = $this->buildingFinder->getByGroup('residential buildings');
     foreach ($residentialBuildings as $id => $building) {
         $counter = $buildingCounters[$id];
         $populationSpace += $counter * $building->getBalancePeople();
     }
     $this->residentialsSpace = $populationSpace;
 }
예제 #3
0
 /**
  * @param \common\models\Base $base
  * @return \frontend\objects\Resources
  */
 public function calculateStorage(Base $base)
 {
     $energy = 0;
     $chemicals = 0;
     $iceAndWater = 0;
     $warehouses = $this->buildingFinder->getByGroup('warehouses');
     $buildingCounters = $base->getBuildingCounters();
     foreach ($warehouses as $id => $building) {
         $counter = $buildingCounters[$id];
         // TODO: Refactor. Each group of buildings could attach specific behaviors
         //       Those could extend the building with needed functionality.
         //       Warehouses: getStorageCapacity( $nWarehouses )
         //       Shelters: getShelterCapacity( $nWarehouses )
         for ($i = 1; i <= $counter; ++$i) {
             $energy += ($i * ($i - 2) + 2) * $building->getStorageEnergy();
             $chemicals += ($i * ($i - 2) + 2) * $building->getStorageChemicals();
             $iceAndWater += ($i * ($i - 2) + 2) * $building->getStorageIceAndWater();
         }
     }
     return new Resources(['iron' => PHP_INT_MAX, 'steel' => PHP_INT_MAX, 'chemicals' => $chemicals, 'vv4a' => PHP_INT_MAX, 'population' => PHP_INT_MAX, 'ice' => $iceAndWater, 'water' => $iceAndWater, 'energy' => $energy, 'credits' => PHP_INT_MAX]);
 }