use std::path::{Path, PathBuf};
use anyhow::Result;
use crate::types::*;
use crate::scene::types::StateEffect;
use crate::state::store::StateStore;
use crate::state::types::GameState;
use super::quickstart::JumpPoint;
pub fn generate_fixtures(dir: &Path) -> Result<Vec<PathBuf>> {
std::fs::create_dir_all(dir)?;
let mut paths = Vec::new();
for jp in JumpPoint::all() {
let state = jp.create_state();
let store = StateStore::from_state(state, dir);
let slug = format!("fixture_{:?}", jp).to_lowercase().replace(' ', "_");
let path = store.save(&slug)?;
paths.push(path);
}
for (branch_name, branch_choice) in &[
("relay_tom", "tom"),
("relay_nella", "nella"),
("relay_papers", "papers"),
] {
let mut state = JumpPoint::RelayTriage.create_state();
state.flags.insert("relay_branch".to_string(), FlagValue::Text(branch_choice.to_string()));
state.flags.insert("poster_born".to_string(), FlagValue::Bool(true));
state.flags.insert("chapter2_complete".to_string(), FlagValue::Bool(true));
match *branch_choice {
"tom" => {
state.flags.insert("nella_died".to_string(), FlagValue::Bool(true));
}
"nella" => {
state.flags.insert("tom_died".to_string(), FlagValue::Bool(true));
}
"papers" => {
state.flags.insert("tom_died".to_string(), FlagValue::Bool(true));
state.flags.insert("nella_died".to_string(), FlagValue::Bool(true));
}
_ => {}
}
state.apply_effect(&StateEffect::UnlockSkill {
character: CharacterId::new("galen"),
skill: SkillId::new("dead_drop"),
});
let store = StateStore::from_state(state, dir);
let path = store.save(branch_name)?;
paths.push(path);
}
for (name, choice) in &[
("prologue_town_direct", "town_direct"),
("prologue_homestead", "homestead_first"),
] {
let mut state = JumpPoint::PrologueCampfire.create_state();
state.flags.insert("beat5_choice".to_string(), FlagValue::Text(choice.to_string()));
state.flags.insert("eli_confession".to_string(), FlagValue::Bool(true));
match *choice {
"town_direct" => {
state.apply_effect(&StateEffect::AdjustReputation {
axis: ReputationAxis::TownLaw, delta: 5,
});
state.apply_effect(&StateEffect::AdjustReputation {
axis: ReputationAxis::Rancher, delta: -10,
});
}
"homestead_first" => {
state.apply_effect(&StateEffect::AdjustReputation {
axis: ReputationAxis::Rancher, delta: 10,
});
state.apply_effect(&StateEffect::AdjustReputation {
axis: ReputationAxis::TownLaw, delta: -10,
});
}
_ => {}
}
let store = StateStore::from_state(state, dir);
let path = store.save(name)?;
paths.push(path);
}
Ok(paths)
}
pub fn print_fixture_summary(paths: &[PathBuf]) {
println!("=== Generated {} fixture saves ===", paths.len());
for path in paths {
if let Some(name) = path.file_stem() {
println!(" {}", name.to_string_lossy());
}
}
}