test(scenes): ✅ Update test cases to verify pathfinding-based reachable target selection in auto-play logic
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
8fb70d59db
commit
9fafc635de
1 changed files with 14 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue