Close DDD cleanup and tests-support closure
This commit is contained in:
@@ -4,12 +4,6 @@ mod domain;
|
||||
mod errors;
|
||||
mod events;
|
||||
|
||||
use serde_json::Value;
|
||||
use shared_contracts::runtime_story::{
|
||||
RuntimeBattlePresentation, RuntimeStoryActionRequest, RuntimeStoryOptionView,
|
||||
RuntimeStoryPatch, RuntimeStorySnapshotPayload,
|
||||
};
|
||||
|
||||
pub mod battle;
|
||||
#[cfg(test)]
|
||||
mod battle_tests;
|
||||
@@ -25,10 +19,12 @@ pub mod prompt_context;
|
||||
pub mod story_engine;
|
||||
pub mod view_model;
|
||||
|
||||
pub use application::*;
|
||||
pub use battle::{
|
||||
build_battle_runtime_story_options, inventory_item_has_usable_effect, resolve_battle_action,
|
||||
restore_player_resource,
|
||||
};
|
||||
pub use commands::*;
|
||||
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,
|
||||
@@ -41,6 +37,9 @@ 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 domain::*;
|
||||
pub use errors::*;
|
||||
pub use events::*;
|
||||
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,
|
||||
@@ -77,94 +76,3 @@ pub use view_model::{
|
||||
build_runtime_story_companions, build_runtime_story_encounter, build_runtime_story_view_model,
|
||||
resolve_current_encounter_npc_state,
|
||||
};
|
||||
|
||||
pub const CONTINUE_ADVENTURE_FUNCTION_ID: &str = "story_continue_adventure";
|
||||
pub const MAX_TASK5_COMPANIONS: usize = 2;
|
||||
|
||||
pub struct StoryResolution {
|
||||
pub action_text: String,
|
||||
pub result_text: String,
|
||||
pub story_text: Option<String>,
|
||||
pub presentation_options: Option<Vec<RuntimeStoryOptionView>>,
|
||||
pub saved_current_story: Option<Value>,
|
||||
pub patches: Vec<RuntimeStoryPatch>,
|
||||
pub battle: Option<RuntimeBattlePresentation>,
|
||||
pub toast: Option<String>,
|
||||
}
|
||||
|
||||
pub struct GeneratedStoryPayload {
|
||||
pub story_text: String,
|
||||
pub history_result_text: String,
|
||||
pub presentation_options: Vec<RuntimeStoryOptionView>,
|
||||
pub saved_current_story: Value,
|
||||
}
|
||||
|
||||
pub struct CurrentEncounterNpcQuestContext {
|
||||
pub npc_id: String,
|
||||
pub npc_name: String,
|
||||
}
|
||||
|
||||
pub struct PendingQuestOfferContext {
|
||||
pub dialogue: Vec<Value>,
|
||||
pub turn_count: i32,
|
||||
pub custom_input_placeholder: String,
|
||||
pub quest: Value,
|
||||
pub quest_id: String,
|
||||
pub intro_text: Option<String>,
|
||||
}
|
||||
|
||||
pub struct RuntimeStoryActionResponseParts {
|
||||
pub requested_session_id: String,
|
||||
pub server_version: u32,
|
||||
pub snapshot: RuntimeStorySnapshotPayload,
|
||||
pub action_text: String,
|
||||
pub result_text: String,
|
||||
pub story_text: String,
|
||||
pub options: Vec<RuntimeStoryOptionView>,
|
||||
pub patches: Vec<RuntimeStoryPatch>,
|
||||
pub toast: Option<String>,
|
||||
pub battle: Option<RuntimeBattlePresentation>,
|
||||
}
|
||||
|
||||
pub fn simple_story_resolution(
|
||||
game_state: &Value,
|
||||
action_text: String,
|
||||
result_text: &str,
|
||||
) -> StoryResolution {
|
||||
StoryResolution {
|
||||
action_text,
|
||||
result_text: result_text.to_string(),
|
||||
story_text: None,
|
||||
presentation_options: None,
|
||||
saved_current_story: None,
|
||||
patches: vec![build_status_patch(game_state)],
|
||||
battle: None,
|
||||
toast: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_action_text(default_text: &str, request: &RuntimeStoryActionRequest) -> String {
|
||||
request
|
||||
.action
|
||||
.payload
|
||||
.as_ref()
|
||||
.and_then(|payload| read_optional_string_field(payload, "optionText"))
|
||||
.unwrap_or_else(|| default_text.to_string())
|
||||
}
|
||||
|
||||
pub fn build_status_patch(game_state: &Value) -> RuntimeStoryPatch {
|
||||
RuntimeStoryPatch::StatusChanged {
|
||||
in_battle: read_bool_field(game_state, "inBattle").unwrap_or(false),
|
||||
npc_interaction_active: read_bool_field(game_state, "npcInteractionActive")
|
||||
.unwrap_or(false),
|
||||
current_npc_battle_mode: read_optional_string_field(game_state, "currentNpcBattleMode"),
|
||||
current_npc_battle_outcome: read_optional_string_field(
|
||||
game_state,
|
||||
"currentNpcBattleOutcome",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_world_type(game_state: &Value) -> Option<String> {
|
||||
read_optional_string_field(game_state, "worldType")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user