Close DDD cleanup and tests-support closure
This commit is contained in:
@@ -1,4 +1,99 @@
|
||||
//! NPC 领域模型过渡落位。
|
||||
//! NPC 领域模型。
|
||||
//!
|
||||
//! 后续迁移 NPC 状态、关系、好感、招募和互动规则时,只保留社交领域变化;
|
||||
//! 战斗初始化和跨表事务由外层编排。
|
||||
//! 本文件只承载 NPC 聚合状态、关系、立场和交互值对象;对话文本、战斗初始化和任务联动由外层应用服务或 adapter 编排。
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "spacetime-types")]
|
||||
use spacetimedb::SpacetimeType;
|
||||
|
||||
pub const NPC_STATE_ID_PREFIX: &str = "npcstate_";
|
||||
pub const MAX_STANCE_NOTES: usize = 3;
|
||||
pub const NPC_RECRUIT_AFFINITY_THRESHOLD: i32 = 60;
|
||||
pub const NPC_PREVIEW_TALK_FUNCTION_ID: &str = "npc_preview_talk";
|
||||
pub const NPC_CHAT_FUNCTION_ID: &str = "npc_chat";
|
||||
pub const NPC_HELP_FUNCTION_ID: &str = "npc_help";
|
||||
pub const NPC_RECRUIT_FUNCTION_ID: &str = "npc_recruit";
|
||||
pub const NPC_FIGHT_FUNCTION_ID: &str = "npc_fight";
|
||||
pub const NPC_SPAR_FUNCTION_ID: &str = "npc_spar";
|
||||
pub const NPC_LEAVE_FUNCTION_ID: &str = "npc_leave";
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum NpcRelationStance {
|
||||
Hostile,
|
||||
Guarded,
|
||||
Neutral,
|
||||
Cooperative,
|
||||
Bonded,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum NpcSocialActionKind {
|
||||
Chat,
|
||||
Help,
|
||||
Gift,
|
||||
Recruit,
|
||||
QuestAccept,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum NpcInteractionStatus {
|
||||
Previewed,
|
||||
Dialogue,
|
||||
Resolved,
|
||||
Recruited,
|
||||
BattlePending,
|
||||
Left,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum NpcInteractionBattleMode {
|
||||
Fight,
|
||||
Spar,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NpcRelationState {
|
||||
pub affinity: i32,
|
||||
pub stance: NpcRelationStance,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NpcStanceProfile {
|
||||
pub trust: u8,
|
||||
pub warmth: u8,
|
||||
pub ideological_fit: u8,
|
||||
pub fear_or_guard: u8,
|
||||
pub loyalty: u8,
|
||||
pub current_conflict_tag: Option<String>,
|
||||
pub recent_approvals: Vec<String>,
|
||||
pub recent_disapprovals: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NpcStateSnapshot {
|
||||
pub npc_state_id: String,
|
||||
pub runtime_session_id: String,
|
||||
pub npc_id: String,
|
||||
pub npc_name: String,
|
||||
pub affinity: i32,
|
||||
pub relation_state: NpcRelationState,
|
||||
pub help_used: bool,
|
||||
pub chatted_count: u32,
|
||||
pub gifts_given: u32,
|
||||
pub recruited: bool,
|
||||
pub trade_stock_signature: Option<String>,
|
||||
pub revealed_facts: Vec<String>,
|
||||
pub known_attribute_rumors: Vec<String>,
|
||||
pub first_meaningful_contact_resolved: bool,
|
||||
pub seen_backstory_chapter_ids: Vec<String>,
|
||||
pub stance_profile: NpcStanceProfile,
|
||||
pub created_at_micros: i64,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user