From fa00b957378a393f8edbfc98ef111d35d18ecb09 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 24 Sep 2023 13:40:25 +0200 Subject: initial commit --- src/Model/Building/ClayPit.php | 16 ++++++++++++++++ src/Model/Building/Farm.php | 31 +++++++++++++++++++++++++++++++ src/Model/Building/IronMine.php | 16 ++++++++++++++++ src/Model/Building/ResourceGenerator.php | 22 ++++++++++++++++++++++ src/Model/Building/Storage.php | 28 ++++++++++++++++++++++++++++ src/Model/Building/TownHall.php | 17 +++++++++++++++++ src/Model/Building/WoodCutter.php | 16 ++++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 src/Model/Building/ClayPit.php create mode 100644 src/Model/Building/Farm.php create mode 100644 src/Model/Building/IronMine.php create mode 100644 src/Model/Building/ResourceGenerator.php create mode 100644 src/Model/Building/Storage.php create mode 100644 src/Model/Building/TownHall.php create mode 100644 src/Model/Building/WoodCutter.php (limited to 'src/Model/Building') 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 @@ + 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 @@ + 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 @@ + 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 @@ +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 @@ + 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 @@ + 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 @@ + 1.0, + ]; + + public string $resourceType = 'wood'; +} -- cgit v1.2.3