This commit is contained in:
2026-05-01 20:29:09 +08:00
parent 8718472dbd
commit 87fbf41fab
137 changed files with 2922 additions and 989 deletions

View File

@@ -947,7 +947,7 @@ fn save_puzzle_generated_images_tx(
draft = replace_puzzle_level(&draft, next_level).map_err(|error| error.to_string())?;
let saved_at = Timestamp::from_micros_since_unix_epoch(input.saved_at_micros);
let next_stage = if build_result_preview(&draft, Some("陶泥")).publish_ready {
let next_stage = if build_result_preview(&draft, Some("百梦")).publish_ready {
PuzzleAgentStage::ReadyToPublish
} else {
PuzzleAgentStage::ImageRefining
@@ -1026,7 +1026,7 @@ fn select_puzzle_cover_image_tx(
};
let draft = replace_puzzle_level(&draft, next_level).map_err(|error| error.to_string())?;
let selected_at = Timestamp::from_micros_since_unix_epoch(input.selected_at_micros);
let next_stage = if build_result_preview(&draft, Some("陶泥")).publish_ready {
let next_stage = if build_result_preview(&draft, Some("百梦")).publish_ready {
PuzzleAgentStage::ReadyToPublish
} else {
PuzzleAgentStage::ImageRefining
@@ -2080,7 +2080,7 @@ fn build_puzzle_agent_session_snapshot(
let messages = list_session_messages(ctx, &row.session_id);
let result_preview = draft
.as_ref()
.map(|value| build_result_preview(value, Some("陶泥")));
.map(|value| build_result_preview(value, Some("百梦")));
Ok(PuzzleAgentSessionSnapshot {
session_id: row.session_id.clone(),
@@ -2268,7 +2268,7 @@ fn upsert_puzzle_draft_work_profile(
profile_id,
owner_user_id.to_string(),
Some(session_id.to_string()),
"陶泥".to_string(),
"百梦".to_string(),
draft,
updated_at_micros,
)
@@ -2565,6 +2565,8 @@ fn upsert_puzzle_profile_save_archive(
};
let world_key = format!("puzzle:{}", run.entry_profile_id);
let target = resolve_puzzle_archive_target(ctx, run, current_level)?;
let work_title = resolve_puzzle_archive_work_title(ctx, &target.profile_id, &target.level_name);
let subtitle = build_puzzle_archive_subtitle(target.level_index, &target.level_name);
// 中文注释:拼图存档只保存恢复入口所需的最小运行态索引,棋盘真相继续放在 puzzle_runtime_run。
let game_state_json = json_to_string(&json!({
@@ -2586,8 +2588,8 @@ fn upsert_puzzle_profile_save_archive(
owner_user_id: target.owner_user_id,
profile_id: Some(run.entry_profile_id.clone()),
world_type: Some("PUZZLE".to_string()),
world_name: target.level_name,
subtitle: format!("第 {} 关", target.level_index),
world_name: work_title,
subtitle,
summary_text: puzzle_archive_summary_text(target.status),
cover_image_src: target.cover_image_src,
bottom_tab: "puzzle".to_string(),
@@ -2682,6 +2684,37 @@ fn resolve_puzzle_archive_target(
})
}
fn resolve_puzzle_archive_work_title(
ctx: &TxContext,
profile_id: &str,
fallback_level_name: &str,
) -> String {
// 中文注释:存档主标题必须是作品名;历史数据或异常行缺失作品名时才回退到关卡名。
ctx.db
.puzzle_work_profile()
.profile_id()
.find(&profile_id.to_string())
.map(|row| {
let title = row.work_title.trim();
if title.is_empty() {
fallback_level_name.to_string()
} else {
title.to_string()
}
})
.unwrap_or_else(|| fallback_level_name.to_string())
}
fn build_puzzle_archive_subtitle(level_index: u32, level_name: &str) -> String {
let level_label = format!("{level_index}");
let level_name = level_name.trim();
if level_name.is_empty() {
level_label
} else {
format!("{level_label} · {level_name}")
}
}
fn resolve_puzzle_current_owner_user_id(ctx: &TxContext, profile_id: &str) -> Option<String> {
ctx.db
.puzzle_work_profile()
@@ -2745,10 +2778,11 @@ fn accrue_puzzle_point_incentive(
play_count: row.play_count,
remix_count: row.remix_count,
like_count: row.like_count,
point_incentive_total_half_points: module_puzzle::puzzle_point_incentive_total_after_spend(
row.point_incentive_total_half_points,
spent_points,
),
point_incentive_total_half_points:
module_puzzle::puzzle_point_incentive_total_after_spend(
row.point_incentive_total_half_points,
spent_points,
),
point_incentive_claimed_points: row.point_incentive_claimed_points,
anchor_pack_json: row.anchor_pack_json.clone(),
publish_ready: row.publish_ready,