refactor: reuse position distance for attacks

This commit is contained in:
Keith Solomon
2026-07-04 15:58:29 -05:00
parent 3c6359243a
commit 7588b304e1
2 changed files with 20 additions and 2 deletions
+1 -2
View File
@@ -53,8 +53,7 @@ final class CombatEngine
throw new CombatException('Target must be an active enemy unit.');
}
$distance = abs($attacker->position->x - $target->position->x)
+ abs($attacker->position->y - $target->position->y);
$distance = $attacker->position->distanceTo($target->position);
if ($distance !== 1) {
throw new CombatException('Target is outside attack range.');