diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-11 13:15:02 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-11 13:15:02 +0100 |
commit | 09caff2b2a06d1f8ac8203567035a21c612165f9 (patch) | |
tree | 999be04ff0a418a33e438be9befc8c9297e383f4 /src/Model/Unit.php | |
parent | 6301f63bd348109b8693a922f02e16d49205a8fd (diff) |
send resources
Diffstat (limited to 'src/Model/Unit.php')
-rw-r--r-- | src/Model/Unit.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Model/Unit.php b/src/Model/Unit.php index 206f5dd..d121aa7 100644 --- a/src/Model/Unit.php +++ b/src/Model/Unit.php @@ -4,6 +4,7 @@ namespace App\Model; use App\DB; use App\Model; +use App\Support\ResourceType; class Unit { @@ -20,8 +21,13 @@ class Unit public string $updatedAt; public string $buildingType; + + public int $buildTimeFactor; + public int $travelTime; + public int $populationDemandFactor; + public array $resourceRequirementsBase = []; public array $resourceRequirementsFactor = []; @@ -30,6 +36,7 @@ class Unit { $unit = new Unit(); $unit->type = $unitType; + $unit->isTraveling = false; $unit->homeVillageId = $villageId; $unit->amount = 0; @@ -45,9 +52,10 @@ class Unit return -1; } - return intval(($_ENV['BASE_UNIT_BUILD_TIME_FACTOR'] / ($building->level ?: 1)) * $amount); + return intval((($_ENV['BASE_UNIT_BUILD_TIME_FACTOR'] * $this->buildTimeFactor) / ($building->level ?: 1)) * $amount); } + public static function getTravelTime(Unit $unit, int $distance): int { return self::getTravelTimePerCell($unit) * $distance; @@ -77,7 +85,7 @@ class Unit )->fetchColumn(); $resourceRequirements = []; - foreach (['wood', 'clay', 'iron', 'food'] as $resourceType) { + foreach (ResourceType::asProperties() as $resourceType) { $base = $unit->resourceRequirementsBase[$resourceType]; $factor = $unit->resourceRequirementsFactor[$resourceType]; @@ -101,6 +109,7 @@ class Unit return $resourceRequirements; } + public function getPopulationDemand(): int { return $this->getPopulationDemandForAmount($this->amount); |