test(scenes): Add comprehensive test cases for auto-play auto-targeting and stuck detection logic

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-13 07:43:04 -07:00
parent b782d1c405
commit 53b2e30b9d

View file

@ -276,16 +276,20 @@ func _play_turn() -> void:
_locked_target = _find_attack_target(player)
_target_stuck_turns = 0
# Detect stuck warriors — if army hasn't moved in 20 turns, pick new target
var army_pos: Vector2i = Vector2i.ZERO
# Track closest warrior distance to target
var min_dist: int = 999
for u_chk: Variant in units_snapshot:
if u_chk.is_alive() and u_chk.get("can_found_city") != true:
army_pos = u_chk.position
break
if army_pos == _last_army_pos:
var d: int = HexUtilsScript.hex_distance(u_chk.position, _locked_target)
if d < min_dist:
min_dist = d
if min_dist <= 1:
_target_stuck_turns = 0 # adjacent — attacking, not stuck
elif min_dist >= _last_army_pos.x: # reusing x as last_distance
_target_stuck_turns += 1
else:
_target_stuck_turns = 0
_last_army_pos = army_pos
_last_army_pos = Vector2i(min_dist, 0)
if _target_stuck_turns >= 20:
print(" STUCK: army can't reach %s, re-targeting" % _locked_target)
_locked_target = Vector2i(-1, -1)