Extend square-hole creation flow with visual asset timeout guard
This commit is contained in:
@@ -3,6 +3,7 @@ use shared_kernel::{normalize_required_string, normalize_string_list};
|
||||
use crate::{
|
||||
SQUARE_HOLE_MAX_DIFFICULTY, SQUARE_HOLE_MAX_SHAPE_COUNT, SQUARE_HOLE_MIN_DIFFICULTY,
|
||||
SQUARE_HOLE_MIN_SHAPE_COUNT, SquareHoleCreatorConfig, SquareHoleError, SquareHoleResultDraft,
|
||||
normalize_hole_options, normalize_shape_options,
|
||||
};
|
||||
|
||||
pub fn validate_shape_count(value: u32) -> Result<u32, SquareHoleError> {
|
||||
@@ -36,6 +37,11 @@ pub fn build_creator_config(
|
||||
twist_rule: normalize_required_string(twist_rule).ok_or(SquareHoleError::MissingText)?,
|
||||
shape_count: validate_shape_count(shape_count)?,
|
||||
difficulty: validate_difficulty(difficulty)?,
|
||||
shape_options: normalize_shape_options(Vec::new(), theme_text),
|
||||
hole_options: normalize_hole_options(Vec::new()),
|
||||
background_prompt: format!("{theme_text}主题的竖屏游戏背景,舞台中央有多个形状洞口"),
|
||||
cover_image_src: None,
|
||||
background_image_src: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -84,6 +90,12 @@ pub fn validate_publish_requirements(draft: &SquareHoleResultDraft) -> Vec<Strin
|
||||
if validate_difficulty(draft.difficulty).is_err() {
|
||||
blockers.push("难度必须在 1 到 10 之间".to_string());
|
||||
}
|
||||
if draft.shape_options.len() < crate::SQUARE_HOLE_MIN_SHAPE_OPTION_COUNT {
|
||||
blockers.push("至少需要 6 个形状图片选项".to_string());
|
||||
}
|
||||
if draft.hole_options.len() < crate::SQUARE_HOLE_MIN_HOLE_OPTION_COUNT {
|
||||
blockers.push("至少需要 3 个洞口选项".to_string());
|
||||
}
|
||||
blockers
|
||||
}
|
||||
|
||||
@@ -104,10 +116,15 @@ pub fn build_result_draft(
|
||||
SquareHoleResultDraft {
|
||||
profile_id,
|
||||
game_name,
|
||||
theme_text,
|
||||
theme_text: theme_text.clone(),
|
||||
twist_rule,
|
||||
summary,
|
||||
tags: build_default_tags("方洞挑战"),
|
||||
cover_image_src: None,
|
||||
background_prompt: format!("{theme_text}主题的竖屏游戏背景,舞台中央有多个形状洞口"),
|
||||
background_image_src: None,
|
||||
shape_options: normalize_shape_options(Vec::new(), &theme_text),
|
||||
hole_options: normalize_hole_options(Vec::new()),
|
||||
shape_count,
|
||||
difficulty,
|
||||
publish_ready: true,
|
||||
|
||||
Reference in New Issue
Block a user