Add branch-aware camp conversations
This commit is contained in:
@@ -6,6 +6,8 @@ const CAMPAIGN_PATH := "res://data/campaign/campaign.json"
|
||||
const SCENARIO_ID := "001_yellow_turbans"
|
||||
const SCENARIO_PATH := "res://data/scenarios/001_yellow_turbans.json"
|
||||
const CONVERSATION_ID := "northern_woods_cache"
|
||||
const BRANCH_SCENARIO_ID := "003_xingyang_ambush"
|
||||
const BRANCH_SCENARIO_PATH := "res://data/scenarios/003_xingyang_ambush.json"
|
||||
const SAVE_PATH := "user://campaign_save.json"
|
||||
const MANUAL_SAVE_PATH := "user://campaign_manual_save.json"
|
||||
|
||||
@@ -19,6 +21,7 @@ func _init() -> void:
|
||||
_check_shop_and_armory_preserve_claim(failures)
|
||||
_check_manual_checkpoint_reverts_claim(failures)
|
||||
_check_completed_replay_cannot_claim(failures)
|
||||
_check_conditional_camp_conversations(failures)
|
||||
|
||||
if not _restore_user_file(SAVE_PATH, save_backup):
|
||||
failures.append("could not restore automatic campaign save")
|
||||
@@ -136,16 +139,81 @@ func _check_completed_replay_cannot_claim(failures: Array[String]) -> void:
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_conditional_camp_conversations(failures: Array[String]) -> void:
|
||||
var no_flags_scene = _new_prebattle_scene_for(failures, "conditional camp no flags", BRANCH_SCENARIO_ID, BRANCH_SCENARIO_PATH)
|
||||
if no_flags_scene != null:
|
||||
if no_flags_scene._camp_conversation_by_id("xingyang_war_council").is_empty():
|
||||
failures.append("Xingyang should expose ungated war council conversation")
|
||||
if not no_flags_scene._camp_conversation_by_id("xingyang_forced_march").is_empty():
|
||||
failures.append("pursuit camp conversation should be hidden without pursuit flag")
|
||||
if not no_flags_scene._camp_conversation_by_id("xingyang_scout_screen").is_empty():
|
||||
failures.append("regroup camp conversation should be hidden without regroup flag")
|
||||
no_flags_scene.free()
|
||||
|
||||
var pursuit_scene = _new_prebattle_scene_for(
|
||||
failures,
|
||||
"conditional camp pursuit",
|
||||
BRANCH_SCENARIO_ID,
|
||||
BRANCH_SCENARIO_PATH,
|
||||
{"pursued_dong_zhuo": true}
|
||||
)
|
||||
if pursuit_scene != null:
|
||||
if pursuit_scene._camp_conversation_by_id("xingyang_forced_march").is_empty():
|
||||
failures.append("pursuit flag should expose forced march conversation")
|
||||
if pursuit_scene._camp_conversation_by_id("xingyang_hasty_stores").is_empty():
|
||||
failures.append("pursuit flag should expose hasty stores conversation")
|
||||
if not pursuit_scene._camp_conversation_by_id("xingyang_scout_screen").is_empty():
|
||||
failures.append("pursuit flag should not expose regroup scout conversation")
|
||||
var hasty_stores: Dictionary = pursuit_scene._camp_conversation_by_id("xingyang_hasty_stores")
|
||||
var before_wine := int(pursuit_scene.campaign_state.get_inventory_snapshot().get("wine", 0))
|
||||
pursuit_scene._apply_camp_conversation_effects(hasty_stores)
|
||||
if int(pursuit_scene.campaign_state.get_inventory_snapshot().get("wine", 0)) != before_wine + 1:
|
||||
failures.append("pursuit hasty stores should add Wine to campaign inventory")
|
||||
if int(pursuit_scene.state.get_inventory_snapshot().get("wine", 0)) != before_wine + 1:
|
||||
failures.append("pursuit hasty stores should refresh battle Wine inventory")
|
||||
pursuit_scene.free()
|
||||
|
||||
var regroup_scene = _new_prebattle_scene_for(
|
||||
failures,
|
||||
"conditional camp regroup",
|
||||
BRANCH_SCENARIO_ID,
|
||||
BRANCH_SCENARIO_PATH,
|
||||
{"regrouped_after_sishui": true}
|
||||
)
|
||||
if regroup_scene != null:
|
||||
if regroup_scene._camp_conversation_by_id("xingyang_scout_screen").is_empty():
|
||||
failures.append("regroup flag should expose scout screen conversation")
|
||||
if regroup_scene._camp_conversation_by_id("xingyang_sishui_supply_train").is_empty():
|
||||
failures.append("regroup flag should expose Sishui supply train conversation")
|
||||
if not regroup_scene._camp_conversation_by_id("xingyang_forced_march").is_empty():
|
||||
failures.append("regroup flag should not expose pursuit forced march conversation")
|
||||
var supply_train: Dictionary = regroup_scene._camp_conversation_by_id("xingyang_sishui_supply_train")
|
||||
var before_panacea := int(regroup_scene.campaign_state.get_inventory_snapshot().get("panacea", 0))
|
||||
regroup_scene._apply_camp_conversation_effects(supply_train)
|
||||
if int(regroup_scene.campaign_state.get_inventory_snapshot().get("panacea", 0)) != before_panacea + 1:
|
||||
failures.append("regroup Sishui supply train should add Panacea to campaign inventory")
|
||||
if int(regroup_scene.state.get_inventory_snapshot().get("panacea", 0)) != before_panacea + 1:
|
||||
failures.append("regroup Sishui supply train should refresh battle Panacea inventory")
|
||||
regroup_scene.free()
|
||||
|
||||
|
||||
func _new_prebattle_scene(failures: Array[String], label: String):
|
||||
return _new_prebattle_scene_for(failures, label, SCENARIO_ID, SCENARIO_PATH)
|
||||
|
||||
|
||||
func _new_prebattle_scene_for(failures: Array[String], label: String, scenario_id: String, scenario_path: String, flag_overrides := {}):
|
||||
var scene = BattleSceneScript.new()
|
||||
if not scene.campaign_state.load_campaign(CAMPAIGN_PATH):
|
||||
failures.append("%s could not load campaign data" % label)
|
||||
scene.free()
|
||||
return null
|
||||
scene.campaign_state.start_new(SCENARIO_ID)
|
||||
scene.active_scenario_id = SCENARIO_ID
|
||||
scene.campaign_state.start_new(scenario_id)
|
||||
if typeof(flag_overrides) == TYPE_DICTIONARY:
|
||||
for flag_name in flag_overrides.keys():
|
||||
scene.campaign_state.flags[str(flag_name)] = flag_overrides[flag_name]
|
||||
scene.active_scenario_id = scenario_id
|
||||
if not scene.state.load_battle(
|
||||
SCENARIO_PATH,
|
||||
scenario_path,
|
||||
scene.campaign_state.get_roster_overrides(),
|
||||
scene.campaign_state.get_inventory_snapshot(),
|
||||
scene.campaign_state.get_flags_snapshot(),
|
||||
|
||||
@@ -1763,6 +1763,13 @@ function Check-Camp-Conversations($Conversations, [string]$ScenarioId) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId references unknown officer: $officerId"
|
||||
}
|
||||
}
|
||||
if (Has-Prop $conversation "campaign_flags") {
|
||||
$conversationFlags = Get-Prop $conversation "campaign_flags" $null
|
||||
if ($null -eq $conversationFlags -or -not ($conversationFlags -is [pscustomobject]) -or @($conversationFlags.PSObject.Properties).Count -le 0) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId campaign_flags must be a non-empty object."
|
||||
}
|
||||
Check-Required-Flags $conversationFlags $ScenarioId "briefing camp_conversations $conversationId"
|
||||
}
|
||||
$conversationLines = Get-Prop $conversation "lines" $null
|
||||
if ($null -eq $conversationLines -or -not ($conversationLines -is [System.Array]) -or @($conversationLines).Count -le 0) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId must have non-empty lines."
|
||||
|
||||
Reference in New Issue
Block a user