This commit is contained in:
2026-04-24 17:59:48 +08:00
parent 929febb4fe
commit 6cb3efae61
55 changed files with 2373 additions and 435 deletions

View File

@@ -976,7 +976,8 @@ fn build_foundation_draft_user_prompt(session: &CustomWorldAgentSessionRecord) -
"3. coreConflicts 必须至少 1 条。".to_string(),
"4. chapters 或 sceneChapterBlueprints 必须体现主线第一幕。".to_string(),
"5. sceneChapterBlueprints[0].acts 至少 1 条。".to_string(),
"6. summary 要像结果页摘要,不要只是原始 seed 重复".to_string(),
"6. sceneChapterBlueprints[*].acts[*].backgroundPromptText 必须逐幕生成,作为每一幕生成背景图时默认填入的场景画面描述,不要只生成一个全局场景背景提示词".to_string(),
"7. summary 要像结果页摘要,不要只是原始 seed 重复。".to_string(),
]
.join("\n\n")
}
@@ -1452,10 +1453,58 @@ fn normalize_scene_chapter_blueprint(chapter: JsonValue) -> JsonValue {
"acts".to_string(),
JsonValue::Array(vec![build_fallback_scene_act()]),
);
} else {
object.insert(
"acts".to_string(),
JsonValue::Array(
acts.into_iter()
.enumerate()
.map(|(index, act)| normalize_scene_act_blueprint(act, index))
.collect(),
),
);
}
JsonValue::Object(object)
}
fn normalize_scene_act_blueprint(act: JsonValue, index: usize) -> JsonValue {
let mut object = act.as_object().cloned().unwrap_or_default();
let fallback_act = build_fallback_scene_act_with_index(index);
let fallback_prompt = fallback_act
.get("backgroundPromptText")
.and_then(JsonValue::as_str)
.unwrap_or("当前幕场景背景,突出可探索空间、站位地面和局势氛围。")
.to_string();
let title = object
.get("title")
.and_then(JsonValue::as_str)
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned)
.unwrap_or_else(|| format!("{}", index + 1));
let summary = object
.get("summary")
.and_then(JsonValue::as_str)
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned)
.unwrap_or_else(|| "当前幕推动场景内的主线压力。".to_string());
object.insert("title".to_string(), JsonValue::String(title.clone()));
object.insert("summary".to_string(), JsonValue::String(summary.clone()));
let background_prompt = object
.get("backgroundPromptText")
.and_then(JsonValue::as_str)
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned)
.unwrap_or_else(|| format!("{title}{summary}{fallback_prompt}"));
object.insert(
"backgroundPromptText".to_string(),
JsonValue::String(background_prompt),
);
JsonValue::Object(object)
}
fn build_fallback_scene_chapter_blueprint() -> JsonValue {
json!({
"id": "chapter-act-1",
@@ -1466,10 +1515,15 @@ fn build_fallback_scene_chapter_blueprint() -> JsonValue {
}
fn build_fallback_scene_act() -> JsonValue {
build_fallback_scene_act_with_index(0)
}
fn build_fallback_scene_act_with_index(index: usize) -> JsonValue {
json!({
"id": "scene-act-1",
"title": "开场场景幕",
"id": format!("scene-act-{}", index + 1),
"title": if index == 0 { "开场场景幕".to_string() } else { format!("{}", index + 1) },
"summary": "玩家被推入第一波局势,必须先确认站位、威胁和下一步追查方向。",
"backgroundPromptText": "第一幕场景背景,突出玩家初入现场时的空间轮廓、可站立地面、远近景层次和第一波威胁氛围。",
})
}