feat: add puzzle clear template runtime
This commit is contained in:
25
server-rs/crates/module-puzzle-clear/src/commands.rs
Normal file
25
server-rs/crates/module-puzzle-clear/src/commands.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use shared_kernel::normalize_required_string;
|
||||
|
||||
use crate::{PuzzleClearOrientation, PuzzleClearShapeKind};
|
||||
|
||||
pub fn parse_puzzle_clear_shape_kind(value: &str) -> PuzzleClearShapeKind {
|
||||
match value.trim().to_ascii_lowercase().as_str() {
|
||||
"1x3" | "one-by-three" => PuzzleClearShapeKind::OneByThree,
|
||||
"2x2" | "two-by-two" => PuzzleClearShapeKind::TwoByTwo,
|
||||
"2x3" | "two-by-three" => PuzzleClearShapeKind::TwoByThree,
|
||||
_ => PuzzleClearShapeKind::OneByTwo,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_puzzle_clear_orientation(value: &str) -> PuzzleClearOrientation {
|
||||
match value.trim().to_ascii_lowercase().as_str() {
|
||||
"vertical" | "纵向" => PuzzleClearOrientation::Vertical,
|
||||
_ => PuzzleClearOrientation::Horizontal,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize_puzzle_clear_seed(seed: &str, fallback: &str) -> String {
|
||||
normalize_required_string(seed)
|
||||
.or_else(|| normalize_required_string(fallback))
|
||||
.unwrap_or_else(|| "puzzle-clear".to_string())
|
||||
}
|
||||
Reference in New Issue
Block a user