feat: add puzzle clear template runtime

This commit is contained in:
2026-06-03 22:11:46 +08:00
parent 6e74cf5add
commit 1b5e098225
148 changed files with 19588 additions and 241 deletions

View 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())
}