summaryrefslogtreecommitdiff
path: root/src/Model/Village.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/Village.php')
-rw-r--r--src/Model/Village.php17
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