Add Nanpi surrender camp flow

This commit is contained in:
2026-06-19 02:29:01 +09:00
parent bda8d02c3c
commit 4087180f72
4 changed files with 321 additions and 1 deletions

View File

@@ -32,9 +32,70 @@
"Nanpi officials already know Cao Cao's terms, and several gate officers are waiting for the safest moment to lay down arms."
]
}
],
"camp_conversations": [
{
"id": "nanpi_surrender_gate_terms",
"group": "topic",
"label": "Gate Surrender Terms",
"speaker": "Cao Cao",
"summary": "Set the terms that will make Nanpi's gate open as law, not panic.",
"lines": [
{ "speaker": "Cao Cao", "side": "left", "text": "A gate opened by fear closes again when the wind changes. A gate opened by terms becomes a border of my command." },
{ "speaker": "Guo Jia", "side": "right", "text": "Then the terms must be heard by soldiers and clerks alike. One group holds spears, the other holds tomorrow." },
{ "speaker": "Zhang He", "side": "right", "text": "The men at the gate know my old rank. If they hear survival from my mouth, Yuan Tan's order will sound thinner." }
]
},
{
"id": "nanpi_surrender_zhang_he_loyalists",
"group": "officer",
"officer_id": "zhang_he",
"label": "Zhang He - Last Loyalists",
"speaker": "Zhang He",
"summary": "Judge which defenders will fight after the surrender bell.",
"lines": [
{ "speaker": "Zhang He", "side": "right", "text": "Most gate officers want to live. The danger is not the fearful man, but the ashamed one who thinks death will repair his name." },
{ "speaker": "Cao Cao", "side": "left", "text": "Then we give the fearful man a road and the ashamed man a warning." }
]
},
{
"id": "nanpi_surrender_pressure_wine",
"campaign_flags": { "pressed_yuan_tan_surrender": true },
"group": "topic",
"label": "Pressure Canteens",
"summary": "Claim wine from the columns that rushed the surrender pressure.",
"lines": [
{ "speaker": "Xiahou Yuan", "side": "right", "text": "The fast columns saved a few wine jars for the gate push. Not enough for comfort, enough to put fire back in the legs." },
{ "speaker": "Guo Jia", "side": "left", "text": "A loud gate needs steady throats. Issue it before Yuan Tan's loyalists spend ours." }
],
"effects": [
{ "type": "grant_item", "item_id": "wine", "count": 1, "text": "The pressure canteens add a Wine to the field supplies." }
]
},
{
"id": "nanpi_surrender_admin_medicine",
"campaign_flags": { "secured_nanpi_admin": true },
"group": "topic",
"label": "Admin Medicine Chest",
"summary": "Claim medicine released by Nanpi clerks who accept Cao Cao's seals.",
"lines": [
{ "speaker": "Cao Ren", "side": "right", "text": "Nanpi clerks brought out a medicine chest under their own seal. They want the city counted as surrendered, not conquered." },
{ "speaker": "Cao Cao", "side": "left", "text": "Good. Let their seal serve our wounded before it serves our records." }
],
"effects": [
{ "type": "grant_item", "item_id": "panacea", "count": 1, "text": "The Nanpi administration medicine chest adds a Panacea to the field supplies." }
]
}
]
},
"shop": {
"merchant": {
"name": "Nanpi Surrender Sutler",
"lines": [
"A surrendering gate is a narrow market, my lord. Everyone wants quiet sandals and loud armor.",
"Buy while the clerks still stamp seals. When the loyalists shout, even honest prices duck behind walls."
]
},
"items": [
"bean",
"wine",

View File

@@ -59,7 +59,7 @@
},
"roster": {
"max_units": 7,
"required_officers": ["cao_cao", "guo_jia"]
"required_officers": ["cao_cao", "guo_jia", "zhang_he"]
},
"formation": {
"cells": [[1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6]]

View File

@@ -74,6 +74,10 @@ const NANPI_PRESSURE_HARD_PUSH_CONVERSATION_ID := "nanpi_pressure_hard_push_bean
const NANPI_PRESSURE_ADMIN_SUPPLY_CONVERSATION_ID := "nanpi_pressure_admin_medicine"
const NANPI_SURRENDER_SCENARIO_ID := "020_nanpi_surrender"
const NANPI_SURRENDER_SCENARIO_PATH := "res://data/scenarios/020_nanpi_surrender.json"
const NANPI_SURRENDER_PRESSURE_CONVERSATION_ID := "nanpi_surrender_pressure_wine"
const NANPI_SURRENDER_ADMIN_CONVERSATION_ID := "nanpi_surrender_admin_medicine"
const BOHAI_SCENARIO_ID := "021_bohai_remnants"
const BOHAI_SCENARIO_PATH := "res://data/scenarios/021_bohai_remnants.json"
const SAVE_PATH := "user://campaign_save.json"
const MANUAL_SAVE_PATH := "user://campaign_manual_save.json"
@@ -102,6 +106,7 @@ func _init() -> void:
_check_ye_surrender_post_battle_choice_bridges_to_northern_pursuit(failures)
_check_northern_pursuit_post_battle_choice_bridges_to_nanpi(failures)
_check_nanpi_post_battle_choice_bridges_to_surrender(failures)
_check_nanpi_surrender_post_battle_choice_bridges_to_bohai(failures)
_check_manual_checkpoint_reverts_claim(failures)
_check_completed_replay_cannot_claim(failures)
_check_conditional_camp_conversations(failures)
@@ -113,6 +118,7 @@ func _init() -> void:
_check_ye_surrender_branch_camp_conversations(failures)
_check_northern_pursuit_branch_camp_conversations(failures)
_check_nanpi_branch_camp_conversations(failures)
_check_nanpi_surrender_branch_camp_conversations(failures)
_check_talk_menu_closes_on_cancel_and_reload(failures)
if not _restore_user_file(SAVE_PATH, save_backup):
@@ -1124,6 +1130,25 @@ func _check_nanpi_post_battle_choice_bridges_to_surrender(failures: Array[String
)
func _check_nanpi_surrender_post_battle_choice_bridges_to_bohai(failures: Array[String]) -> void:
_check_nanpi_surrender_choice_branch_to_bohai(
failures,
"pursue_yuan_brothers",
"pursued_yuan_brothers",
"secured_bohai_commandery",
"war_drum",
"imperial_seal"
)
_check_nanpi_surrender_choice_branch_to_bohai(
failures,
"secure_bohai_commandery",
"secured_bohai_commandery",
"pursued_yuan_brothers",
"imperial_seal",
"war_drum"
)
func _check_wuchao_choice_branch_to_cangting(
failures: Array[String],
choice_id: String,
@@ -1635,6 +1660,79 @@ func _check_nanpi_choice_branch_to_surrender(
scene.free()
func _check_nanpi_surrender_choice_branch_to_bohai(
failures: Array[String],
choice_id: String,
expected_flag: String,
cleared_flag: String,
expected_shop_item_id: String,
hidden_shop_item_id: String
) -> void:
var scene = _new_prebattle_scene_for(failures, "Nanpi Surrender choice bridge %s" % choice_id, NANPI_SURRENDER_SCENARIO_ID, NANPI_SURRENDER_SCENARIO_PATH)
if scene == null:
return
if not scene.campaign_state.joined_officers.has("zhang_he"):
scene.campaign_state.joined_officers.append("zhang_he")
if not scene.state.load_battle(
NANPI_SURRENDER_SCENARIO_PATH,
scene.campaign_state.get_roster_overrides(),
scene.campaign_state.get_inventory_snapshot(),
scene.campaign_state.get_flags_snapshot(),
scene.campaign_state.get_joined_officers_snapshot()
):
failures.append("Nanpi Surrender choice bridge %s could not reload Nanpi Surrender with Zhang He joined" % choice_id)
scene.free()
return
scene.state.battle_status = "victory"
var result: Dictionary = scene.campaign_state.apply_battle_result(scene.state)
if not bool(result.get("saved", false)):
failures.append("Nanpi Surrender choice bridge %s should save 020 victory" % choice_id)
scene.free()
return
if not scene.campaign_state.get_joined_officers_snapshot().has("zhang_he"):
failures.append("Nanpi Surrender choice bridge %s should keep Zhang He before Bohai" % choice_id)
if bool(result.get("choice_applied", true)):
failures.append("Nanpi Surrender choice bridge %s should wait for a selected post-battle choice" % choice_id)
if scene.campaign_state.pending_post_battle_choice_scenario_id != NANPI_SURRENDER_SCENARIO_ID:
failures.append("Nanpi Surrender choice bridge %s should mark Nanpi Surrender choice pending" % choice_id)
var choice := _find_choice_by_id(result.get("post_battle_choices", []), choice_id)
if choice.is_empty():
failures.append("Nanpi Surrender choice bridge missing choice: %s" % choice_id)
scene.free()
return
if not scene.campaign_state.try_apply_post_battle_choice(choice, NANPI_SURRENDER_SCENARIO_ID):
failures.append("Nanpi Surrender choice bridge %s should save selected choice" % choice_id)
scene.free()
return
var flags: Dictionary = scene.campaign_state.get_flags_snapshot()
if flags.get(expected_flag, false) != true:
failures.append("Nanpi Surrender choice bridge %s should set %s" % [choice_id, expected_flag])
if flags.get(cleared_flag, true) != false:
failures.append("Nanpi Surrender choice bridge %s should clear %s" % [choice_id, cleared_flag])
if scene.campaign_state.current_scenario_id != BOHAI_SCENARIO_ID:
failures.append("Nanpi Surrender choice bridge %s should advance to Bohai, got %s" % [choice_id, scene.campaign_state.current_scenario_id])
if not scene.state.load_battle(
BOHAI_SCENARIO_PATH,
scene.campaign_state.get_roster_overrides(),
scene.campaign_state.get_inventory_snapshot(),
flags,
scene.campaign_state.get_joined_officers_snapshot()
):
failures.append("Nanpi Surrender choice bridge %s could not load Bohai" % choice_id)
scene.free()
return
if scene.state.get_unit("zhang_he_ch21").is_empty():
failures.append("Nanpi Surrender choice bridge %s should deploy Zhang He in Bohai" % choice_id)
elif not scene.state.is_required_deployment("zhang_he_ch21"):
failures.append("Nanpi Surrender choice bridge %s should require Zhang He in Bohai" % choice_id)
var shop_items: Array = scene.state.get_shop_item_ids()
if not shop_items.has(expected_shop_item_id):
failures.append("Nanpi Surrender choice bridge %s should expose shop item %s" % [choice_id, expected_shop_item_id])
if shop_items.has(hidden_shop_item_id):
failures.append("Nanpi Surrender choice bridge %s should hide shop item %s" % [choice_id, hidden_shop_item_id])
scene.free()
func _find_choice_by_id(choices, choice_id: String) -> Dictionary:
if typeof(choices) != TYPE_ARRAY:
return {}
@@ -2392,6 +2490,88 @@ func _check_nanpi_branch_camp_conversations(failures: Array[String]) -> void:
secured_scene.free()
func _check_nanpi_surrender_branch_camp_conversations(failures: Array[String]) -> void:
var base_scene = _new_prebattle_scene_for(failures, "Nanpi Surrender base camp", NANPI_SURRENDER_SCENARIO_ID, NANPI_SURRENDER_SCENARIO_PATH)
if base_scene != null:
if base_scene._camp_conversation_by_id("nanpi_surrender_gate_terms").is_empty():
failures.append("Nanpi Surrender should expose the gate terms conversation")
if base_scene._camp_conversation_by_id("nanpi_surrender_zhang_he_loyalists").is_empty():
failures.append("Nanpi Surrender should expose Zhang He's loyalists conversation")
if not base_scene._camp_conversation_by_id(NANPI_SURRENDER_PRESSURE_CONVERSATION_ID).is_empty():
failures.append("Nanpi Surrender pressure wine should be hidden without direct pressure flag")
if not base_scene._camp_conversation_by_id(NANPI_SURRENDER_ADMIN_CONVERSATION_ID).is_empty():
failures.append("Nanpi Surrender admin medicine should be hidden without Nanpi admin flag")
var merchant: Dictionary = base_scene.state.get_shop_merchant()
if str(merchant.get("name", "")) != "Nanpi Surrender Sutler":
failures.append("Nanpi Surrender shop merchant name should be present")
var merchant_lines: Array = merchant.get("lines", [])
if merchant_lines.size() < 2:
failures.append("Nanpi Surrender shop merchant should expose flavor lines")
if base_scene._format_talk_status_text(base_scene._camp_conversation_entries()) != "Camp conversations | 2 topics":
failures.append("Nanpi Surrender base talk status should summarize two non-supply topics")
base_scene.free()
var pressure_scene = _new_prebattle_scene_for(
failures,
"Nanpi Surrender pressure camp",
NANPI_SURRENDER_SCENARIO_ID,
NANPI_SURRENDER_SCENARIO_PATH,
{"pressed_yuan_tan_surrender": true}
)
if pressure_scene != null:
var pressure_wine: Dictionary = pressure_scene._camp_conversation_by_id(NANPI_SURRENDER_PRESSURE_CONVERSATION_ID)
if pressure_wine.is_empty():
failures.append("pressed Yuan Tan surrender flag should expose Nanpi Surrender pressure wine")
if not pressure_scene._camp_conversation_by_id(NANPI_SURRENDER_ADMIN_CONVERSATION_ID).is_empty():
failures.append("pressed Yuan Tan surrender flag should not expose Nanpi Surrender admin medicine")
if not pressure_wine.is_empty():
if pressure_scene._format_talk_status_text(pressure_scene._camp_conversation_entries()) != "Camp conversations | 3 topics | 1 supplies ready":
failures.append("Nanpi Surrender pressure talk status should show one ready supply")
if not pressure_scene._format_camp_conversation_button_text(pressure_wine).contains("Supply Wine"):
failures.append("Nanpi Surrender pressure wine button should show Wine supply")
var before_wine := int(pressure_scene.campaign_state.get_inventory_snapshot().get("wine", 0))
pressure_scene._apply_camp_conversation_effects(pressure_wine)
if int(pressure_scene.campaign_state.get_inventory_snapshot().get("wine", 0)) != before_wine + 1:
failures.append("Nanpi Surrender pressure wine should add Wine to campaign inventory")
if int(pressure_scene.state.get_inventory_snapshot().get("wine", 0)) != before_wine + 1:
failures.append("Nanpi Surrender pressure wine should refresh battle Wine inventory")
if not pressure_scene.campaign_state.has_claimed_camp_conversation_effects(NANPI_SURRENDER_SCENARIO_ID, NANPI_SURRENDER_PRESSURE_CONVERSATION_ID):
failures.append("Nanpi Surrender pressure wine claim should be saved")
if pressure_scene._format_talk_status_text(pressure_scene._camp_conversation_entries()) != "Camp conversations | 3 topics | 1 claimed":
failures.append("Nanpi Surrender pressure talk status should show claimed supply after claim")
pressure_scene.free()
var admin_scene = _new_prebattle_scene_for(
failures,
"Nanpi Surrender admin camp",
NANPI_SURRENDER_SCENARIO_ID,
NANPI_SURRENDER_SCENARIO_PATH,
{"secured_nanpi_admin": true}
)
if admin_scene != null:
var admin_medicine: Dictionary = admin_scene._camp_conversation_by_id(NANPI_SURRENDER_ADMIN_CONVERSATION_ID)
if admin_medicine.is_empty():
failures.append("secured Nanpi admin flag should expose Nanpi Surrender admin medicine")
if not admin_scene._camp_conversation_by_id(NANPI_SURRENDER_PRESSURE_CONVERSATION_ID).is_empty():
failures.append("secured Nanpi admin flag should not expose Nanpi Surrender pressure wine")
if not admin_medicine.is_empty():
if admin_scene._format_talk_status_text(admin_scene._camp_conversation_entries()) != "Camp conversations | 3 topics | 1 supplies ready":
failures.append("Nanpi Surrender admin talk status should show one ready supply")
if not admin_scene._format_camp_conversation_button_text(admin_medicine).contains("Supply Panacea"):
failures.append("Nanpi Surrender admin medicine button should show Panacea supply")
var before_panacea := int(admin_scene.campaign_state.get_inventory_snapshot().get("panacea", 0))
admin_scene._apply_camp_conversation_effects(admin_medicine)
if int(admin_scene.campaign_state.get_inventory_snapshot().get("panacea", 0)) != before_panacea + 1:
failures.append("Nanpi Surrender admin medicine should add Panacea to campaign inventory")
if int(admin_scene.state.get_inventory_snapshot().get("panacea", 0)) != before_panacea + 1:
failures.append("Nanpi Surrender admin medicine should refresh battle Panacea inventory")
if not admin_scene.campaign_state.has_claimed_camp_conversation_effects(NANPI_SURRENDER_SCENARIO_ID, NANPI_SURRENDER_ADMIN_CONVERSATION_ID):
failures.append("Nanpi Surrender admin medicine claim should be saved")
if admin_scene._format_talk_status_text(admin_scene._camp_conversation_entries()) != "Camp conversations | 3 topics | 1 claimed":
failures.append("Nanpi Surrender admin talk status should show claimed supply after claim")
admin_scene.free()
func _check_talk_menu_closes_on_cancel_and_reload(failures: Array[String]) -> void:
var scene = _new_prebattle_scene(failures, "talk menu close guards")
if scene == null:

View File

@@ -1186,6 +1186,85 @@ func _check_battle_visual_data(failures: Array[String]) -> void:
).is_empty():
failures.append("019 old Northern Pursuit flags should not expose admin medicine")
var nanpi_surrender_state = BattleStateScript.new()
if not nanpi_surrender_state.load_battle("res://data/scenarios/020_nanpi_surrender.json"):
failures.append("could not load Nanpi Surrender camp data")
else:
_check_shop_items_unique(failures, nanpi_surrender_state, "020 base")
var nanpi_surrender_conversations: Array = nanpi_surrender_state.get_briefing().get("camp_conversations", [])
if nanpi_surrender_conversations.size() != 2:
failures.append("020 base briefing should expose exactly two camp conversations")
else:
_check_camp_conversation(failures, nanpi_surrender_conversations[0], "nanpi_surrender_gate_terms", "topic", "")
_check_camp_conversation(failures, nanpi_surrender_conversations[1], "nanpi_surrender_zhang_he_loyalists", "officer", "zhang_he")
var nanpi_surrender_merchant := nanpi_surrender_state.get_shop_merchant()
if str(nanpi_surrender_merchant.get("name", "")) != "Nanpi Surrender Sutler":
failures.append("020 shop should expose Nanpi Surrender merchant name")
if (nanpi_surrender_merchant.get("lines", []) as Array).size() < 2:
failures.append("020 shop should expose merchant flavor lines")
_check_shop_item_visibility(failures, nanpi_surrender_state, "war_drum", false, "020 base")
_check_shop_item_visibility(failures, nanpi_surrender_state, "imperial_seal", false, "020 base")
_check_shop_item_visibility(failures, nanpi_surrender_state, "iron_armor", true, "020 base")
var nanpi_surrender_pressure_state = BattleStateScript.new()
if not nanpi_surrender_pressure_state.load_battle("res://data/scenarios/020_nanpi_surrender.json", {}, {}, {"pressed_yuan_tan_surrender": true}):
failures.append("could not load Nanpi Surrender pressure camp data")
else:
_check_shop_items_unique(failures, nanpi_surrender_pressure_state, "020 pressed Yuan Tan surrender")
var pressure_wine: Dictionary = _find_camp_conversation(
nanpi_surrender_pressure_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_pressure_wine"
)
if pressure_wine.is_empty():
failures.append("020 pressed Yuan Tan surrender flag should expose pressure wine")
else:
_check_camp_conversation_effect(failures, pressure_wine, "wine", 1)
if not _find_camp_conversation(
nanpi_surrender_pressure_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_admin_medicine"
).is_empty():
failures.append("020 pressed Yuan Tan surrender flag should not expose admin medicine")
_check_shop_item_visibility(failures, nanpi_surrender_pressure_state, "war_drum", true, "020 pressed Yuan Tan surrender")
_check_shop_item_visibility(failures, nanpi_surrender_pressure_state, "imperial_seal", false, "020 pressed Yuan Tan surrender")
var nanpi_surrender_admin_state = BattleStateScript.new()
if not nanpi_surrender_admin_state.load_battle("res://data/scenarios/020_nanpi_surrender.json", {}, {}, {"secured_nanpi_admin": true}):
failures.append("could not load Nanpi Surrender admin camp data")
else:
_check_shop_items_unique(failures, nanpi_surrender_admin_state, "020 secured Nanpi admin")
var surrender_admin_medicine: Dictionary = _find_camp_conversation(
nanpi_surrender_admin_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_admin_medicine"
)
if surrender_admin_medicine.is_empty():
failures.append("020 secured Nanpi admin flag should expose admin medicine")
else:
_check_camp_conversation_effect(failures, surrender_admin_medicine, "panacea", 1)
if not _find_camp_conversation(
nanpi_surrender_admin_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_pressure_wine"
).is_empty():
failures.append("020 secured Nanpi admin flag should not expose pressure wine")
_check_shop_item_visibility(failures, nanpi_surrender_admin_state, "war_drum", false, "020 secured Nanpi admin")
_check_shop_item_visibility(failures, nanpi_surrender_admin_state, "imperial_seal", true, "020 secured Nanpi admin")
var nanpi_surrender_old_flags_state = BattleStateScript.new()
if not nanpi_surrender_old_flags_state.load_battle("res://data/scenarios/020_nanpi_surrender.json", {}, {}, {"pressed_north_to_nanpi": true, "secured_ji_province": true}):
failures.append("could not load Nanpi Surrender old Nanpi Pressure flag camp data")
else:
_check_shop_item_visibility(failures, nanpi_surrender_old_flags_state, "war_drum", false, "020 old Nanpi Pressure flags")
_check_shop_item_visibility(failures, nanpi_surrender_old_flags_state, "imperial_seal", false, "020 old Nanpi Pressure flags")
if not _find_camp_conversation(
nanpi_surrender_old_flags_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_pressure_wine"
).is_empty():
failures.append("020 old Nanpi Pressure flags should not expose pressure wine")
if not _find_camp_conversation(
nanpi_surrender_old_flags_state.get_briefing().get("camp_conversations", []),
"nanpi_surrender_admin_medicine"
).is_empty():
failures.append("020 old Nanpi Pressure flags should not expose admin medicine")
for item_id in ["bronze_sword", "training_spear", "short_bow", "hand_axe", "iron_armor", "panacea"]:
var item := state.get_item_def(item_id)
if item.is_empty():