132 lines
4.2 KiB
GDScript
132 lines
4.2 KiB
GDScript
extends SceneTree
|
|
|
|
const BattleSceneScript := preload("res://scripts/scenes/battle_scene.gd")
|
|
|
|
|
|
func _init() -> void:
|
|
var failures: Array[String] = []
|
|
var scene = BattleSceneScript.new()
|
|
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
|
|
push_error("Could not load smoke scenario.")
|
|
quit(1)
|
|
return
|
|
if not scene.campaign_state.load_campaign("res://data/campaign/campaign.json"):
|
|
push_error("Could not load smoke campaign.")
|
|
quit(1)
|
|
return
|
|
scene.campaign_state.start_new("001_yellow_turbans")
|
|
scene.campaign_state.gold = 320
|
|
|
|
scene.battle_result_summary = {
|
|
"saved": true,
|
|
"rewards_applied": true,
|
|
"already_completed": false,
|
|
"pending_choice": false,
|
|
"gold": 100,
|
|
"items": ["bean", "bean"],
|
|
"joined_officers": ["dian_wei"],
|
|
"left_officers": [],
|
|
"progression_events": [
|
|
{"type": "level_up", "name": "Cao Cao", "to_level": 2}
|
|
],
|
|
"next_scenario_id": "002_sishui_gate",
|
|
"next_scenario_title": "Sishui Gate",
|
|
"choice_applied": true,
|
|
"choice_label": ""
|
|
}
|
|
var result_text: String = scene._format_battle_result_summary()
|
|
_check_contains(failures, "reward section", result_text, "Spoils")
|
|
_check_contains(failures, "gold reward", result_text, "Gold +100")
|
|
_check_contains(failures, "item reward", result_text, "Bean x2")
|
|
_check_contains(failures, "roster section", result_text, "Joined: Dian Wei")
|
|
_check_contains(failures, "growth section", result_text, "Cao Cao Lv.2")
|
|
_check_contains(failures, "campaign section", result_text, "Next March: Sishui Gate")
|
|
_check_contains(failures, "next camp section", result_text, "Next Encampment")
|
|
_check_contains(failures, "next camp location", result_text, "Sishui Gate, 190 CE")
|
|
_check_contains(failures, "next camp talk", result_text, "Council 3")
|
|
_check_contains(failures, "next camp shop", result_text, "Market 6 goods")
|
|
_check_contains(failures, "next camp deploy", result_text, "Muster 2/3")
|
|
_check_contains(failures, "next camp formation", result_text, "Array 6 tiles")
|
|
|
|
scene.battle_result_summary = {
|
|
"saved": false,
|
|
"rewards_applied": false,
|
|
"already_completed": false,
|
|
"pending_choice": false,
|
|
"gold": 0,
|
|
"items": [],
|
|
"joined_officers": [],
|
|
"left_officers": [],
|
|
"progression_events": [],
|
|
"next_scenario_title": "Sishui Gate",
|
|
"choice_applied": true,
|
|
"choice_label": ""
|
|
}
|
|
var failed_save_text: String = scene._format_battle_result_summary()
|
|
_check_contains(failures, "failed rewards", failed_save_text, "Not recorded")
|
|
_check_contains(failures, "failed save", failed_save_text, "Chronicle seal failed")
|
|
|
|
scene.battle_result_summary = {
|
|
"saved": true,
|
|
"pending_choice": true,
|
|
"next_scenario_id": "002_sishui_gate",
|
|
"next_scenario_title": "Qingzhou Campaign"
|
|
}
|
|
var pending_choice_text := scene._format_battle_result_summary()
|
|
_check_contains(
|
|
failures,
|
|
"pending choice prompt",
|
|
pending_choice_text,
|
|
"Select a response"
|
|
)
|
|
_check_not_contains(
|
|
failures,
|
|
"pending choice should wait for response before next camp preview",
|
|
pending_choice_text,
|
|
"Next Encampment"
|
|
)
|
|
|
|
scene.battle_result_summary = {
|
|
"saved": true,
|
|
"already_completed": true,
|
|
"next_scenario_title": "Current Battle"
|
|
}
|
|
_check_contains(
|
|
failures,
|
|
"replay rewards",
|
|
scene._format_battle_result_summary(),
|
|
"Already claimed"
|
|
)
|
|
|
|
var choice_text: String = scene._format_post_battle_choice_reward_text({
|
|
"gold": 50,
|
|
"items": ["war_axe"],
|
|
"join_officers": ["dian_wei"]
|
|
})
|
|
_check_contains(failures, "choice gold", choice_text, "+50G")
|
|
_check_contains(failures, "choice item", choice_text, "War Axe")
|
|
_check_contains(failures, "choice join", choice_text, "Join Dian Wei")
|
|
|
|
if failures.is_empty():
|
|
scene.free()
|
|
print("result summary smoke ok")
|
|
quit(0)
|
|
return
|
|
|
|
scene.free()
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
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])
|
|
|
|
|
|
func _check_not_contains(failures: Array[String], label: String, text: String, unexpected: String) -> void:
|
|
if not text.contains(unexpected):
|
|
return
|
|
failures.append("%s did not expect `%s` in `%s`" % [label, unexpected, text])
|