39 lines
1.4 KiB
Rust
39 lines
1.4 KiB
Rust
//! NPC 领域错误。
|
|
//!
|
|
//! 错误只表达互动规则失败,例如状态不允许、好感不足或目标非法。
|
|
|
|
use std::{error::Error, fmt};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum NpcStateFieldError {
|
|
MissingRuntimeSessionId,
|
|
MissingNpcId,
|
|
MissingNpcName,
|
|
MissingInteractionFunctionId,
|
|
HelpAlreadyUsed,
|
|
RecruitAffinityTooLow,
|
|
UnsupportedInteractionFunctionId,
|
|
}
|
|
|
|
impl fmt::Display for NpcStateFieldError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::MissingRuntimeSessionId => f.write_str("npc_state.runtime_session_id 不能为空"),
|
|
Self::MissingNpcId => f.write_str("npc_state.npc_id 不能为空"),
|
|
Self::MissingNpcName => f.write_str("npc_state.npc_name 不能为空"),
|
|
Self::MissingInteractionFunctionId => {
|
|
f.write_str("resolve_npc_interaction.interaction_function_id 不能为空")
|
|
}
|
|
Self::HelpAlreadyUsed => f.write_str("npc_state.help_used 已经消耗,不能重复援手"),
|
|
Self::RecruitAffinityTooLow => {
|
|
f.write_str("npc_state.affinity 未达到招募阈值,不能执行招募动作")
|
|
}
|
|
Self::UnsupportedInteractionFunctionId => {
|
|
f.write_str("resolve_npc_interaction.interaction_function_id 当前不受支持")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for NpcStateFieldError {}
|