Close DDD refactor and remove generated asset proxy
This commit is contained in:
@@ -11,6 +11,19 @@ pub struct BeginStorySessionRequest {
|
||||
pub opening_summary: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BeginStoryRuntimeSessionRequest {
|
||||
pub world_type: String,
|
||||
#[serde(default)]
|
||||
pub custom_world_profile: Option<Value>,
|
||||
pub character: Value,
|
||||
#[serde(default)]
|
||||
pub runtime_mode: Option<String>,
|
||||
#[serde(default)]
|
||||
pub disable_persistence: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ContinueStoryRequest {
|
||||
@@ -20,6 +33,20 @@ pub struct ContinueStoryRequest {
|
||||
pub choice_function_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ResolveStoryRuntimeActionRequest {
|
||||
pub story_session_id: String,
|
||||
#[serde(default)]
|
||||
pub client_version: Option<u32>,
|
||||
pub function_id: String,
|
||||
pub action_text: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub target_id: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub payload: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StorySessionPayload {
|
||||
@@ -65,6 +92,17 @@ pub struct StorySessionStateResponse {
|
||||
pub story_events: Vec<StoryEventPayload>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoryRuntimeSnapshotPayload {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub saved_at: Option<String>,
|
||||
pub bottom_tab: String,
|
||||
pub game_state: Value,
|
||||
#[serde(default)]
|
||||
pub current_story: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoryRuntimeProjectionRequest {
|
||||
@@ -126,6 +164,7 @@ pub struct StoryRuntimeProjectionResponse {
|
||||
pub story_session: StorySessionPayload,
|
||||
pub story_events: Vec<StoryEventPayload>,
|
||||
pub server_version: u32,
|
||||
pub game_state: Value,
|
||||
pub actor: StoryRuntimeActorProjection,
|
||||
pub inventory: StoryRuntimeInventoryProjection,
|
||||
pub options: Vec<StoryRuntimeOptionProjection>,
|
||||
@@ -138,6 +177,12 @@ pub struct StoryRuntimeProjectionResponse {
|
||||
pub toast: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoryRuntimeMutationResponse {
|
||||
pub projection: StoryRuntimeProjectionResponse,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoryBattleRewardItemRequest {
|
||||
@@ -476,6 +521,11 @@ mod tests {
|
||||
created_at: "2.000000Z".to_string(),
|
||||
}],
|
||||
server_version: 2,
|
||||
game_state: json!({
|
||||
"runtimeSessionId": "runtime_1",
|
||||
"storySessionId": "storysess_1",
|
||||
"currentScene": "Story"
|
||||
}),
|
||||
actor: StoryRuntimeActorProjection {
|
||||
hp: 32,
|
||||
max_hp: 40,
|
||||
@@ -516,6 +566,7 @@ mod tests {
|
||||
json!("storysess_1")
|
||||
);
|
||||
assert_eq!(payload["serverVersion"], json!(2));
|
||||
assert_eq!(payload["gameState"]["storySessionId"], json!("storysess_1"));
|
||||
assert_eq!(payload["actor"]["maxHp"], json!(40));
|
||||
assert_eq!(
|
||||
payload["inventory"]["backpackItems"][0]["name"],
|
||||
@@ -527,6 +578,69 @@ mod tests {
|
||||
assert!(payload.get("presentation").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn story_runtime_mutation_response_wraps_projection_only() {
|
||||
let payload = serde_json::to_value(StoryRuntimeMutationResponse {
|
||||
projection: StoryRuntimeProjectionResponse {
|
||||
story_session: StorySessionPayload {
|
||||
story_session_id: "storysess_1".to_string(),
|
||||
runtime_session_id: "runtime_1".to_string(),
|
||||
actor_user_id: "user_1".to_string(),
|
||||
world_profile_id: "profile_1".to_string(),
|
||||
initial_prompt: "进入营地".to_string(),
|
||||
opening_summary: Some("营地开场".to_string()),
|
||||
latest_narrative_text: "营火还亮着。".to_string(),
|
||||
latest_choice_function_id: None,
|
||||
status: "active".to_string(),
|
||||
version: 1,
|
||||
created_at: "1.000000Z".to_string(),
|
||||
updated_at: "1.000000Z".to_string(),
|
||||
},
|
||||
story_events: Vec::new(),
|
||||
server_version: 1,
|
||||
game_state: json!({
|
||||
"runtimeSessionId": "runtime_1",
|
||||
"storySessionId": "storysess_1",
|
||||
"currentScene": "Story"
|
||||
}),
|
||||
actor: StoryRuntimeActorProjection {
|
||||
hp: 40,
|
||||
max_hp: 40,
|
||||
mana: 20,
|
||||
max_mana: 20,
|
||||
currency: 0,
|
||||
currency_text: "0 铜钱".to_string(),
|
||||
},
|
||||
inventory: StoryRuntimeInventoryProjection {
|
||||
backpack_items: Vec::new(),
|
||||
equipment_slots: Vec::new(),
|
||||
forge_recipes: Vec::new(),
|
||||
},
|
||||
options: Vec::new(),
|
||||
status: StoryRuntimeStatusProjection {
|
||||
in_battle: false,
|
||||
npc_interaction_active: false,
|
||||
current_encounter_id: None,
|
||||
current_npc_battle_mode: None,
|
||||
current_npc_battle_outcome: None,
|
||||
},
|
||||
current_narrative_text: Some("营火还亮着。".to_string()),
|
||||
action_result_text: None,
|
||||
toast: None,
|
||||
},
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
assert_eq!(
|
||||
payload["projection"]["storySession"]["storySessionId"],
|
||||
json!("storysess_1")
|
||||
);
|
||||
assert_eq!(payload["projection"]["serverVersion"], json!(1));
|
||||
assert!(payload.get("snapshot").is_none());
|
||||
assert!(payload.get("viewModel").is_none());
|
||||
assert!(payload.get("presentation").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn story_battle_responses_use_story_contract_shape() {
|
||||
let battle_state = StoryBattleStatePayload {
|
||||
|
||||
Reference in New Issue
Block a user