refactor: reuse position distance for attacks
This commit is contained in:
1 parent
3c6359243a
commit
7588b304e1
2 files changed
+20
-2
No files matched your search
@@ -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.');
|
||||
|
||||
Reference in new issue
Block a user