diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index 0f0e8981..25590d09 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -205,6 +205,8 @@ func _play_turn() -> void: var units_snapshot: Array = player.units.duplicate() + var city_pos: Vector2i = player.cities[0].position if not player.cities.is_empty() else Vector2i.ZERO + if military_count >= 4: # ATTACK PHASE: march all units toward nearest enemy city var target: Vector2i = _find_attack_target(player) @@ -213,14 +215,27 @@ func _play_turn() -> void: print(" ATTACK: %d warriors marching to %s" % [military_count, target]) for u: Variant in units_snapshot: if u.is_alive() and u.movement_remaining > 0 and u.get("can_found_city") != true: + # Un-fortify before moving + u.is_fortified = false + u.fortified_turns = 0 _move_toward(u, target, game_map) else: - # BUILD PHASE: keep units at home, only scout explores + # BUILD PHASE: fortify warriors at city, only scout explores for u: Variant in units_snapshot: - if u.is_alive() and u.movement_remaining > 0: - if u.type_id == "dwarf_scout": - _explore(u, player, game_map) - # Warriors stay at city for defense + if not u.is_alive() or u.movement_remaining <= 0: + continue + if u.get("can_found_city") == true: + continue + if u.type_id == "dwarf_scout" and _turn_count <= 15: + _explore(u, player, game_map) + else: + # Fortify at city for defense bonus + if u.position == city_pos: + u.is_fortified = true + u.movement_remaining = 0 + else: + # Move back to city + _move_toward(u, city_pos, game_map) func _try_found_city(player: RefCounted, _game_map: RefCounted) -> void: