Close DDD refactor and remove generated asset proxy
This commit is contained in:
@@ -3,26 +3,10 @@
|
||||
//! 这里组合纯领域规则并返回后端投影;真实保存、SSE 和模型调用由外层完成。
|
||||
|
||||
use serde_json::Value;
|
||||
use shared_contracts::runtime_story::{
|
||||
RuntimeBattlePresentation, RuntimeStoryOptionView, RuntimeStoryPatch,
|
||||
RuntimeStorySnapshotPayload,
|
||||
};
|
||||
use shared_contracts::runtime_story::RuntimeStoryPatch;
|
||||
|
||||
use crate::{StoryResolution, read_bool_field, read_optional_string_field};
|
||||
|
||||
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,
|
||||
|
||||
@@ -58,7 +58,6 @@ fn build_request(function_id: &str, option_text: &str) -> RuntimeStoryActionRequ
|
||||
"optionText": option_text
|
||||
})),
|
||||
},
|
||||
snapshot: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1085
server-rs/crates/module-runtime-story/src/bootstrap.rs
Normal file
1085
server-rs/crates/module-runtime-story/src/bootstrap.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,12 @@
|
||||
#![recursion_limit = "512"]
|
||||
|
||||
mod application;
|
||||
mod bootstrap;
|
||||
mod commands;
|
||||
mod domain;
|
||||
mod errors;
|
||||
mod events;
|
||||
mod session_action;
|
||||
|
||||
pub mod battle;
|
||||
#[cfg(test)]
|
||||
@@ -24,6 +28,11 @@ pub use battle::{
|
||||
build_battle_runtime_story_options, inventory_item_has_usable_effect, resolve_battle_action,
|
||||
restore_player_resource,
|
||||
};
|
||||
pub use bootstrap::{
|
||||
RuntimeStoryBootstrapBuild, RuntimeStoryBootstrapSeed, build_custom_scene_preset,
|
||||
build_encounter_from_scene_npc, build_runtime_story_bootstrap, generate_runtime_session_id,
|
||||
resolve_custom_runtime_scene_id,
|
||||
};
|
||||
pub use commands::*;
|
||||
pub use core::{
|
||||
MAX_PLAYER_LEVEL, add_player_currency, add_player_inventory_items, append_active_build_buffs,
|
||||
@@ -71,6 +80,10 @@ pub use post_battle::{
|
||||
};
|
||||
pub use projection::{StoryRuntimeProjectionSource, build_story_runtime_projection};
|
||||
pub use prompt_context::{RuntimeStoryPromptContextExtras, build_runtime_story_prompt_context};
|
||||
pub use session_action::{
|
||||
StoryRuntimeActionResolveInput, StoryRuntimeActionResolveOutput, build_runtime_story_options,
|
||||
build_runtime_story_state_response_parts, resolve_story_runtime_action,
|
||||
};
|
||||
pub use story_engine::project_story_engine_after_action;
|
||||
pub use view_model::{
|
||||
build_runtime_story_companions, build_runtime_story_encounter, build_runtime_story_view_model,
|
||||
|
||||
@@ -35,6 +35,7 @@ pub fn build_story_runtime_projection(
|
||||
story_session: source.story_session,
|
||||
story_events: source.story_events,
|
||||
server_version: source.server_version,
|
||||
game_state: source.game_state.clone(),
|
||||
actor: StoryRuntimeActorProjection {
|
||||
hp: read_i32_field(&source.game_state, "playerHp").unwrap_or(0),
|
||||
max_hp: read_i32_field(&source.game_state, "playerMaxHp").unwrap_or(1),
|
||||
@@ -174,6 +175,7 @@ mod tests {
|
||||
});
|
||||
|
||||
assert_eq!(projection.story_session.story_session_id, "storysess_1");
|
||||
assert_eq!(projection.game_state["worldType"], json!("WUXIA"));
|
||||
assert_eq!(projection.actor.hp, 28);
|
||||
assert_eq!(projection.actor.currency_text, "80 铜钱");
|
||||
assert_eq!(projection.inventory.backpack_items.len(), 1);
|
||||
|
||||
1578
server-rs/crates/module-runtime-story/src/session_action.rs
Normal file
1578
server-rs/crates/module-runtime-story/src/session_action.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user