feat: add puzzle clear template runtime
This commit is contained in:
37
server-rs/crates/module-puzzle-clear/src/errors.rs
Normal file
37
server-rs/crates/module-puzzle-clear/src/errors.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum PuzzleClearError {
|
||||
MissingRunId,
|
||||
MissingOwnerUserId,
|
||||
MissingProfileId,
|
||||
InvalidLevel,
|
||||
InvalidBoard,
|
||||
InvalidPosition,
|
||||
EmptyDeck,
|
||||
NoPlayableMove,
|
||||
RunNotPlaying,
|
||||
LevelExpired,
|
||||
MissingCard,
|
||||
}
|
||||
|
||||
impl fmt::Display for PuzzleClearError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let message = match self {
|
||||
Self::MissingRunId => "puzzle-clear run_id 不能为空",
|
||||
Self::MissingOwnerUserId => "puzzle-clear owner_user_id 不能为空",
|
||||
Self::MissingProfileId => "puzzle-clear profile_id 不能为空",
|
||||
Self::InvalidLevel => "puzzle-clear 关卡配置无效",
|
||||
Self::InvalidBoard => "puzzle-clear 棋盘状态无效",
|
||||
Self::InvalidPosition => "puzzle-clear 坐标无效",
|
||||
Self::EmptyDeck => "puzzle-clear 发牌池为空",
|
||||
Self::NoPlayableMove => "puzzle-clear 棋盘没有可解拼接",
|
||||
Self::RunNotPlaying => "puzzle-clear 当前 run 不在 playing 状态",
|
||||
Self::LevelExpired => "puzzle-clear 当前关卡已经超时",
|
||||
Self::MissingCard => "puzzle-clear 目标格子没有卡牌",
|
||||
};
|
||||
f.write_str(message)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for PuzzleClearError {}
|
||||
Reference in New Issue
Block a user