diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-09-24 13:40:25 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-09-24 13:40:25 +0200 |
commit | fa00b957378a393f8edbfc98ef111d35d18ecb09 (patch) | |
tree | 654e7dc5414f7f2795dbe996d3e1570793a5b1b8 /src/Model/Building/Farm.php |
initial commit
Diffstat (limited to 'src/Model/Building/Farm.php')
-rw-r--r-- | src/Model/Building/Farm.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Model/Building/Farm.php b/src/Model/Building/Farm.php new file mode 100644 index 0000000..aaa58b5 --- /dev/null +++ b/src/Model/Building/Farm.php @@ -0,0 +1,31 @@ +<?php + +namespace App\Model\Building; + +use App\Model\Unit; +use App\Model\Village; + +class Farm extends ResourceGenerator +{ + public string $unitType = 'Farmer'; + public int $buildTimeFactor = 1; + public int $maxLevel = 25; + + public array $resourceRequirements = [ + 'wood' => 1.0, + ]; + + public string $resourceType = 'food'; + + public function getResourceIncrementor(): int + { + $populationDemand = array_reduce( + Village::getUnits($this->villageId, Village::FETCH_UNIT_RESIDENCE), + function ($carry, Unit $unit) { + return $carry + $unit->getPopulationDemand(); + } + ); + + return parent::getResourceIncrementor() - $populationDemand; + } +} |