summaryrefslogtreecommitdiff
path: root/src/Model/Building
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/Building')
-rw-r--r--src/Model/Building/ClayPit.php16
-rw-r--r--src/Model/Building/Farm.php31
-rw-r--r--src/Model/Building/IronMine.php16
-rw-r--r--src/Model/Building/ResourceGenerator.php22
-rw-r--r--src/Model/Building/Storage.php28
-rw-r--r--src/Model/Building/TownHall.php17
-rw-r--r--src/Model/Building/WoodCutter.php16
7 files changed, 146 insertions, 0 deletions
diff --git a/src/Model/Building/ClayPit.php b/src/Model/Building/ClayPit.php
new file mode 100644
index 0000000..8127818
--- /dev/null
+++ b/src/Model/Building/ClayPit.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model\Building;
+
+class ClayPit extends ResourceGenerator
+{
+ public string $unitType = 'PitWorker';
+ public int $buildTimeFactor = 1;
+ public int $maxLevel = 25;
+
+ public array $resourceRequirements = [
+ 'wood' => 1.0,
+ ];
+
+ public string $resourceType = 'clay';
+}
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;
+ }
+}
diff --git a/src/Model/Building/IronMine.php b/src/Model/Building/IronMine.php
new file mode 100644
index 0000000..4bf5cc6
--- /dev/null
+++ b/src/Model/Building/IronMine.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model\Building;
+
+class IronMine extends ResourceGenerator
+{
+ public string $unitType = 'Miner';
+ public int $buildTimeFactor = 1;
+ public int $maxLevel = 25;
+
+ public array $resourceRequirements = [
+ 'wood' => 1.0,
+ ];
+
+ public string $resourceType = 'iron';
+}
diff --git a/src/Model/Building/ResourceGenerator.php b/src/Model/Building/ResourceGenerator.php
new file mode 100644
index 0000000..5f1a6bb
--- /dev/null
+++ b/src/Model/Building/ResourceGenerator.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Model\Building;
+
+use App\Model\Building;
+use App\Model\Unit;
+
+class ResourceGenerator extends Building
+{
+ public string $resourceType;
+
+ public function getResourceIncrementor(): int
+ {
+ $amountResiding = Unit::getAmountResiding($this->unitType, $this->villageId);
+
+ return (int)ceil(
+ log(
+ ($this->level * $amountResiding) + 1
+ ) * $_ENV['BASE_RESOURCE_GENERATION_FACTOR']
+ );
+ }
+}
diff --git a/src/Model/Building/Storage.php b/src/Model/Building/Storage.php
new file mode 100644
index 0000000..fde4c4e
--- /dev/null
+++ b/src/Model/Building/Storage.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Model\Building;
+
+use App\Model\Building;
+use App\Model\Village;
+
+class Storage extends Building
+{
+ public int $buildTimeFactor = 1;
+ public int $maxLevel = 25;
+
+ public array $resourceRequirements = [
+ 'wood' => 1.0,
+ ];
+
+ public function getCapacity(): int
+ {
+ return $this->level * 2560;
+ }
+
+ public function getResourceCapacity(string $resourceType): int
+ {
+ $p = Village::getStorageConfig($this->villageId)->$resourceType / 100;
+
+ return ceil($this->getCapacity() * $p);
+ }
+}
diff --git a/src/Model/Building/TownHall.php b/src/Model/Building/TownHall.php
new file mode 100644
index 0000000..608f083
--- /dev/null
+++ b/src/Model/Building/TownHall.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Model\Building;
+
+use App\Model\Building;
+
+class TownHall extends Building
+{
+ public int $buildTimeFactor = 1;
+ public int $maxLevel = 25;
+
+ public array $resourceRequirements = [
+ 'wood' => 1.0,
+ 'clay' => 1.0,
+ 'iron' => 1.0,
+ ];
+}
diff --git a/src/Model/Building/WoodCutter.php b/src/Model/Building/WoodCutter.php
new file mode 100644
index 0000000..86bde9b
--- /dev/null
+++ b/src/Model/Building/WoodCutter.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model\Building;
+
+class WoodCutter extends ResourceGenerator
+{
+ public string $unitType = 'WoodCutter';
+ public int $buildTimeFactor = 1;
+ public int $maxLevel = 25;
+
+ public array $resourceRequirements = [
+ 'wood' => 1.0,
+ ];
+
+ public string $resourceType = 'wood';
+}