Close DDD refactor and remove generated asset proxy
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
5. `src/errors.rs` 承载 runtime story 纯规则错误。
|
||||
6. `src/lib.rs` 只保留模块声明、公开导出和子模块 re-export。
|
||||
|
||||
后续 WP-RS 继续按 battle / forge / NPC / quest / presentation 的顺序,把旧 `/api/runtime/story/*` 写侧能力迁到 session scoped 新接口,并删除运行代码中的旧入口命名。
|
||||
`bootstrap.rs` 需要组装较深的运行时初始 `game_state` JSON 模板,crate 级 `recursion_limit = "512"` 仅用于支撑 `serde_json::json!` 宏展开,不承载额外领域规则。
|
||||
|
||||
当前 WP-RS 写链路已经通过 `POST /api/story/sessions/runtime` 和 `POST /api/story/sessions/{storySessionId}/actions/resolve` 收口到 session scoped 新接口。后续只按 battle / forge / NPC / quest / presentation 的顺序增强领域规则和投影,并在 `WP-DEL` 中删除运行代码不再需要的旧入口命名。
|
||||
|
||||
配套记录见 [../../../docs/technical/SERVER_RS_DDD_WP_RS_RUNTIME_STORY_DOMAIN_SPLIT_2026-04-30.md](../../../docs/technical/SERVER_RS_DDD_WP_RS_RUNTIME_STORY_DOMAIN_SPLIT_2026-04-30.md)。
|
||||
|
||||
@@ -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