test(@projects/@magic-civilization): 🐛 load units catalog before add_player_militarist (p2_58b)

Same p2-71c guard as turn_processor: both _make_state and the barren-tile test
called add_player_militarist without set_units_runtime_catalog_json, so no player
spawned. Harvest the runtime catalog first.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-06-24 04:00:51 -04:00
parent 3ebf7bf42f
commit 5adedf911d

View file

@ -78,6 +78,11 @@ func _make_state(grid: RefCounted) -> RefCounted:
assert_not_null(state, "GdGameState must be registered")
## Attach the pre-seeded fauna grid.
state.call("set_grid_from_gridstate", grid)
## p2-71c — add_player_militarist refuses to spawn without the runtime units
## catalog (MapUnit base_moves=0 otherwise). Load it before spawning.
var units_json: String = AiTurnBridge._harvest_runtime_units_json()
if not units_json.is_empty():
state.call("set_units_runtime_catalog_json", units_json)
## Add one militarist player. Unit spawns near FAUNA_COL/ROW via
## add_player_militarist which places units close to the city.
## We use the fauna tile coordinates directly as the city so the unit
@ -130,6 +135,9 @@ func test_ambient_encounter_count_zero_on_barren_tile() -> void:
if not is_instance_valid(state):
return
state.call("set_grid_from_gridstate", grid)
var units_json: String = AiTurnBridge._harvest_runtime_units_json()
if not units_json.is_empty():
state.call("set_units_runtime_catalog_json", units_json)
state.call("add_player_militarist", FAUNA_COL, FAUNA_ROW)
state.set("seed", 42)