This commit is contained in:
dingo
2026-04-14 09:41:52 -04:00
parent 470d7c38fc
commit d1a78e672a
5 changed files with 66 additions and 23 deletions
+18 -1
View File
@@ -725,7 +725,24 @@ public static class GameEngine
// Target counter-attacks if able and still alive.
if (target.CurrentHealth > 0 && target.CanAttack && !target.IsExhausted)
ApplyDamage(attacker, target.Damage ?? 0);
{
var canCounterAttack = true;
if (state.Board is not null && target.Position.HasValue && attacker.Position.HasValue)
{
var occupancy = state.Board.BuildOccupancyMap();
var targetMinRange = target.MinAttackRange ?? 1;
var targetMaxRange = target.MaxAttackRange ?? 1;
canCounterAttack = AttackSystem.CanAttack(
target.Position.Value, attacker.Position.Value,
targetMinRange, targetMaxRange, target.RequiresLos,
state.Board, occupancy);
}
if (canCounterAttack)
ApplyDamage(attacker, target.Damage ?? 0);
}
// Consume extra attack or exhaust normally.
if (attacker.ExtraAttacksRemaining > 0)