diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-10-04 11:32:04 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-10-04 11:32:04 +0200 |
commit | 94a3dd52da3ae180af37c6fd0e8c24b3562da388 (patch) | |
tree | acced055660bfd65ca3e955ea26d412457ba4507 /src/Model/Village.php | |
parent | fa00b957378a393f8edbfc98ef111d35d18ecb09 (diff) |
initial commit 2
Diffstat (limited to 'src/Model/Village.php')
-rw-r--r-- | src/Model/Village.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Model/Village.php b/src/Model/Village.php index cd1c749..b1ab19e 100644 --- a/src/Model/Village.php +++ b/src/Model/Village.php @@ -41,6 +41,18 @@ class Village return true; } + public static function canTrain(Village $village, Unit $unit, int $amount): bool + { + $resourceRequirements = Unit::getResourceRequirements($unit, $amount); + foreach ($resourceRequirements as $resourceType => $requirement) { + if ($village->$resourceType < $requirement) { + return false; + } + } + + return true; + } + /* DB - Actions */ public static function get(int $id): ?Village @@ -61,6 +73,11 @@ class Village ); } + public static function getDistance(int $x, int $y, int $dx, int $dy): int + { + return abs($x - $dx) + abs($y - $dy); + } + /* DB - Relations */ public static function getBuildings(int $villageId): array |