diff options
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); |