diff --git a/README.md b/README.md index ecedb81..b24b022 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble - show histograms - author name in solutions and blueprints ### undecided +- option to skip (speed through with settable multiplier) first N stages, for when you are debugging something that happens in later stages - hide some tile tools in early levels to make it less overwhelming - footprint score (tiles that were non-empty at any point in the run) - option to use 8-bit marbles? diff --git a/src/main.rs b/src/main.rs index 5db9b89..6d0e32c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,11 +46,8 @@ fn main() { impl Game { fn new(rl: &mut RaylibHandle, thread: &RaylibThread) -> Self { - let mut chapters = get_chapters(); let solutions = get_solutions(); - if let Some(orphans) = find_orphans(&chapters, &solutions) { - chapters.push(orphans); - } + let chapters = get_chapters(&solutions); Self { chapters, @@ -358,11 +355,23 @@ impl Game { } } -fn get_chapters() -> Vec { +fn get_chapters(solutions: &HashMap>) -> Vec { let mut chapters = Vec::::new(); for d in read_dir("levels").unwrap().flatten() { if let Ok(text) = read_to_string(d.path()) { - if let Ok(chapter) = serde_json::from_str(&text) { + if let Ok(mut chapter) = serde_json::from_str::(&text) { + chapter.visible = false; + for level in &chapter.levels { + if solutions + .get(level.id()) + .map(|s| s.iter().any(|s| s.score.is_some())) + != Some(true) + { + // only expand chapters where at least one level has no complete solutions + chapter.visible = true; + break; + } + } chapters.push(chapter); } } @@ -386,7 +395,9 @@ fn get_chapters() -> Vec { levels: custom_levels, visible: true, }); - + if let Some(orphans) = find_orphans(&chapters, solutions) { + chapters.push(orphans); + } chapters }