From 9fafc635de5e0ecb3cac086567b6155fa174fed4 Mon Sep 17 00:00:00 2001 From: autocommit Date: Mon, 13 Apr 2026 07:31:51 -0700 Subject: [PATCH] =?UTF-8?q?test(scenes):=20=E2=9C=85=20Update=20test=20cas?= =?UTF-8?q?es=20to=20verify=20pathfinding-based=20reachable=20target=20sel?= =?UTF-8?q?ection=20in=20auto-play=20logic?= 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index ccf56754..8585b009 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -495,13 +495,26 @@ func _find_attack_target(player: RefCounted) -> Vector2i: var best_pos: Vector2i = Vector2i(-1, -1) var best_dist: int = 999 - # Target nearest enemy city (skip pathfinding — just use hex distance) + # Target nearest enemy city — try pathfinding first, fall back to hex distance for p: Variant in GameState.players: if p.index == player.index: continue for c: Variant in p.cities: var dist: int = HexUtilsScript.hex_distance(my_pos, c.position) if dist < best_dist: + # Verify reachable by land (short budget to avoid wraparound issues) + if game_map != null: + var reachable: Dictionary = PathfinderScript.movement_range( + game_map, my_pos, dist + 5, "land" + ) + # Check if any reachable hex is within 2 of the target + var can_reach: bool = false + for rpos: Vector2i in reachable: + if HexUtilsScript.hex_distance(rpos, c.position) <= 2: + can_reach = true + break + if not can_reach: + continue best_dist = dist best_pos = c.position