From 09caff2b2a06d1f8ac8203567035a21c612165f9 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 11 Jan 2024 13:15:02 +0100 Subject: send resources --- src/Model/Building.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Model/Building.php') diff --git a/src/Model/Building.php b/src/Model/Building.php index e42af03..36bdc68 100644 --- a/src/Model/Building.php +++ b/src/Model/Building.php @@ -4,6 +4,7 @@ namespace App\Model; use App\DB; use App\Model; +use App\Support\ResourceType; class Building { @@ -17,11 +18,15 @@ class Building public \DateTime $updatedAt; public string $unitType; + public int $buildTimeFactor; + public array $resourceRequirementsBase; public array $resourceRequirementsFactor; + public array $buildingRequirements; public array $techRequirements; + public int $maxLevel; @@ -80,6 +85,7 @@ class Building return $this->level + count($upgradeEvents); } + public function getBuildTime(): int { return $this->getBuildTimeForLevel($this->level + 1); @@ -92,6 +98,7 @@ class Building return intval($level * ($level / $townHall->level) * $_ENV['BASE_BUILDING_BUILD_TIME_FACTOR'] * $this->buildTimeFactor); } + /** * @return array */ @@ -106,7 +113,7 @@ class Building public function getResourceRequirementsForLevel(int $level): array { $resourceRequirements = []; - foreach (['wood', 'clay', 'iron'] as $resourceType) { + foreach (ResourceType::asPropertiesForBuildings() as $resourceType) { $base = $this->resourceRequirementsBase[$resourceType]; $factor = $this->resourceRequirementsFactor[$resourceType]; -- cgit v1.2.3