test(scene): ✅ Add test for auto-play target re-targeting to prevent stuck armies
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
9fafc635de
commit
f2ad1471c7
1 changed files with 18 additions and 0 deletions
|
|
@ -18,6 +18,8 @@ var _world_map: Node = null
|
|||
var _founded_city: bool = false
|
||||
var _screenshot_interval: int = 10
|
||||
var _locked_target: Vector2i = Vector2i(-1, -1)
|
||||
var _target_stuck_turns: int = 0
|
||||
var _last_army_pos: Vector2i = Vector2i(-1, -1)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -272,6 +274,22 @@ func _play_turn() -> void:
|
|||
target_alive = true
|
||||
if not target_alive:
|
||||
_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
|
||||
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:
|
||||
_target_stuck_turns += 1
|
||||
else:
|
||||
_target_stuck_turns = 0
|
||||
_last_army_pos = army_pos
|
||||
if _target_stuck_turns >= 20:
|
||||
print(" STUCK: army can't reach %s, re-targeting" % _locked_target)
|
||||
_locked_target = Vector2i(-1, -1)
|
||||
_target_stuck_turns = 0
|
||||
var target: Vector2i = _locked_target
|
||||
if target != Vector2i(-1, -1):
|
||||
if _turn_count % 10 == 0:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue