80 lines
2.0 KiB
GDScript
80 lines
2.0 KiB
GDScript
extends SceneTree
|
|
|
|
const BattleStateScript := preload("res://scripts/core/battle_state.gd")
|
|
|
|
|
|
func _init() -> void:
|
|
var failures: Array[String] = []
|
|
|
|
_check_contains(
|
|
failures,
|
|
"001 HUD progress",
|
|
_progress_text("res://data/scenarios/001_yellow_turbans.json", false),
|
|
"Enemies defeated 0/"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"001 briefing progress",
|
|
_defeat_text("res://data/scenarios/001_yellow_turbans.json"),
|
|
"Allies remaining"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"002 gated victory progress",
|
|
_progress_text("res://data/scenarios/002_sishui_gate.json", false),
|
|
"Objective unlocks on Turn 2"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"002 pending enemy progress",
|
|
_progress_text("res://data/scenarios/002_sishui_gate.json", false),
|
|
"Enemies defeated 0/"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"007 destination progress",
|
|
_progress_text("res://data/scenarios/007_xian_emperor_escort.json", false),
|
|
"Destination (14, 5): not reached"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"007 protected-unit risk progress",
|
|
_defeat_text("res://data/scenarios/007_xian_emperor_escort.json"),
|
|
"Imperial Envoy safe"
|
|
)
|
|
_check_contains(
|
|
failures,
|
|
"045 gated destination progress",
|
|
_progress_text("res://data/scenarios/045_fancheng_relief.json", false),
|
|
"Reach (10, 5): not reached"
|
|
)
|
|
|
|
if failures.is_empty():
|
|
print("objective progress smoke ok")
|
|
quit(0)
|
|
return
|
|
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func _progress_text(path: String, include_defeat_risks: bool) -> String:
|
|
var state = BattleStateScript.new()
|
|
if not state.load_battle(path):
|
|
return "<load failed: %s>" % path
|
|
return state.get_objective_progress_text(include_defeat_risks)
|
|
|
|
|
|
func _defeat_text(path: String) -> String:
|
|
var state = BattleStateScript.new()
|
|
if not state.load_battle(path):
|
|
return "<load failed: %s>" % path
|
|
return state.get_defeat_progress_text()
|
|
|
|
|
|
func _check_contains(failures: Array[String], label: String, text: String, expected: String) -> void:
|
|
if text.contains(expected):
|
|
return
|
|
failures.append("%s expected `%s` in `%s`" % [label, expected, text])
|