From ba116c791e5607470c86fa466fa1c26784872e49 Mon Sep 17 00:00:00 2001 From: autocommit Date: Wed, 15 Apr 2026 23:28:22 -0700 Subject: [PATCH] =?UTF-8?q?test(scenes):=20=E2=9C=85=20Update=20auto-play?= =?UTF-8?q?=20test=20scenarios=20to=20reflect=20scene=20behavior=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/game/engine/scenes/tests/auto_play.gd | 27 +++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index ebfa9799..6ed5928b 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -1271,14 +1271,37 @@ func _command_worker(unit: Variant, player: RefCounted, game_map: RefCounted) -> best_dist = d best_target = tpos if best_target != Vector2i(-1, -1): - _move_toward(unit, best_target, game_map) + _worker_step_toward(unit, best_target, game_map) return if not player.cities.is_empty(): - _move_toward(unit, player.cities[0].position, game_map) + _worker_step_toward(unit, player.cities[0].position, game_map) else: _explore(unit, player, game_map) +func _worker_step_toward(unit: Variant, target: Vector2i, game_map: RefCounted) -> void: + # Workers must step ONTO the target tile to build on it — do not use the + # attack-adjacent shortcut in _move_toward which skips movement entirely. + if unit.position == target: + return + var reachable: Dictionary = PathfinderScript.movement_range( + game_map, unit.position, unit.movement_remaining, "land" + ) + if reachable.is_empty(): + return + var best_pos: Vector2i = unit.position + var best_dist: int = HexUtilsScript.hex_distance(unit.position, target) + for pos: Vector2i in reachable: + if pos == unit.position: + continue + var dist: int = HexUtilsScript.hex_distance(pos, target) + if dist < best_dist: + best_dist = dist + best_pos = pos + if best_pos != unit.position: + _do_move(unit, best_pos, game_map) + + func _nearest_city_to_target(player: RefCounted) -> RefCounted: ## Return the player's city closest to the locked attack target. ## Falls back to city[0] if no target is locked.