拆分大文件

This commit is contained in:
2026-04-23 23:38:00 +08:00
parent 53a9cdd791
commit 8df502b2a7
506 changed files with 11312 additions and 13069 deletions

View File

@@ -1,8 +1,7 @@
use serde_json::{Map, Value, json};
use shared_contracts::runtime_story::{
RuntimeBattlePresentation, RuntimeStoryActionRequest, RuntimeStoryOptionView,
RuntimeStoryPatch,
RuntimeBattlePresentation, RuntimeStoryActionRequest, RuntimeStoryOptionView, RuntimeStoryPatch,
};
use crate::{
@@ -471,7 +470,10 @@ fn read_player_inventory_items(game_state: &Value) -> Vec<BattleInventoryItemVie
.collect()
}
fn find_player_inventory_item(game_state: &Value, item_id: &str) -> Option<BattleInventoryItemView> {
fn find_player_inventory_item(
game_state: &Value,
item_id: &str,
) -> Option<BattleInventoryItemView> {
read_player_inventory_items(game_state)
.into_iter()
.find(|item| item.id == item_id)
@@ -798,10 +800,7 @@ fn build_inventory_use_battle_action_plan(
})
}
fn battle_action_toast(
function_id: &str,
request: &RuntimeStoryActionRequest,
) -> Option<String> {
fn battle_action_toast(function_id: &str, request: &RuntimeStoryActionRequest) -> Option<String> {
if function_id != "inventory_use" {
return None;
}

View File

@@ -115,7 +115,10 @@ pub fn resolve_forge_dismantle_action(
next_inventory = remove_inventory_item_from_list(next_inventory, item_id.as_str(), 1);
next_inventory = add_inventory_items_to_list(next_inventory, outputs.clone());
write_player_inventory_values(game_state, next_inventory);
let output_names = outputs.iter().map(read_inventory_item_name).collect::<Vec<_>>();
let output_names = outputs
.iter()
.map(read_inventory_item_name)
.collect::<Vec<_>>();
Ok(StoryResolution {
action_text: resolve_action_text(

View File

@@ -13,6 +13,9 @@ pub mod npc_support;
pub mod options;
pub mod view_model;
pub use battle::{
build_battle_runtime_story_options, resolve_battle_action, restore_player_resource,
};
pub use core::{
MAX_PLAYER_LEVEL, add_player_currency, add_player_inventory_items, append_active_build_buffs,
append_story_history, clear_encounter_only, clear_encounter_state, cumulative_xp_required,
@@ -25,27 +28,26 @@ pub use core::{
write_first_hostile_npc_i32_field, write_i32_field, write_null_field, write_string_field,
write_u32_field, xp_to_next_level_for,
};
pub use forge::{build_runtime_equipment_item, build_runtime_material_item, format_currency_text};
pub use forge_actions::{
resolve_forge_craft_action, resolve_forge_dismantle_action, resolve_forge_reforge_action,
};
pub use game_state::{
add_inventory_items_to_list, apply_equipment_loadout_to_state, battle_mode_text,
build_current_build_toast, clone_inventory_item_with_quantity, current_encounter_id,
current_encounter_name, current_encounter_name_from_battle, ensure_inventory_action_available,
equipment_bonus_fallbacks, equipment_item_bonuses, equipment_slot_label,
find_player_inventory_entry, has_giftable_player_inventory, item_rarity_key,
normalize_equipped_item, normalize_equipment_slot_id, read_equipment_total_bonuses,
normalize_equipment_slot_id, normalize_equipped_item, read_equipment_total_bonuses,
read_inventory_item_name, read_player_equipment_item, read_player_inventory_values,
read_runtime_equipment_bonus_cache, remove_inventory_item_from_list,
resolve_equipment_slot_for_item, write_player_equipment_item, write_player_inventory_values,
write_runtime_equipment_bonus_cache,
};
pub use forge::{build_runtime_equipment_item, build_runtime_material_item, format_currency_text};
pub use forge_actions::{
resolve_forge_craft_action, resolve_forge_dismantle_action, resolve_forge_reforge_action,
};
pub use npc_support::{
build_npc_gift_result_text, npc_buyback_price, npc_purchase_price, recruit_companion_to_party,
resolve_npc_gift_affinity_gain, trade_quantity_suffix,
};
pub use battle::{build_battle_runtime_story_options, resolve_battle_action, restore_player_resource};
pub use options::{
build_disabled_runtime_story_option, build_runtime_story_option_from_story_option,
build_runtime_story_option_interaction, build_runtime_story_option_with_payload,

View File

@@ -1,12 +1,8 @@
use serde_json::Value;
use shared_contracts::runtime_story::{
RuntimeStoryOptionInteraction, RuntimeStoryOptionView,
};
use shared_contracts::runtime_story::{RuntimeStoryOptionInteraction, RuntimeStoryOptionView};
use crate::{
read_bool_field, read_field, read_optional_string_field, read_required_string_field,
};
use crate::{read_bool_field, read_field, read_optional_string_field, read_required_string_field};
/// 这批 helper 只负责 runtime story option 的纯 DTO 编译,不触碰 HTTP / AppState。
pub fn infer_option_scope(function_id: &str) -> &'static str {

View File

@@ -38,9 +38,7 @@ pub fn build_runtime_story_view_model(
}
}
pub fn build_runtime_story_companions(
game_state: &Value,
) -> Vec<RuntimeStoryCompanionViewModel> {
pub fn build_runtime_story_companions(game_state: &Value) -> Vec<RuntimeStoryCompanionViewModel> {
read_array_field(game_state, "companions")
.into_iter()
.filter_map(|entry| {
@@ -54,9 +52,7 @@ pub fn build_runtime_story_companions(
.collect()
}
pub fn build_runtime_story_encounter(
game_state: &Value,
) -> Option<RuntimeStoryEncounterViewModel> {
pub fn build_runtime_story_encounter(game_state: &Value) -> Option<RuntimeStoryEncounterViewModel> {
let encounter = read_object_field(game_state, "currentEncounter")?;
let npc_name = read_required_string_field(encounter, "npcName")
.or_else(|| read_required_string_field(encounter, "name"))