Skip to content

Commit

Permalink
Resolve latent release state loading newer tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Nov 16, 2024
1 parent 0ef788a commit 2248d33
Show file tree
Hide file tree
Showing 6 changed files with 923 additions and 6 deletions.
2 changes: 1 addition & 1 deletion truncate_client/src/handle_launch_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn handle_launch_code(
"TUTORIAL_RULES" => {
return Some(GameStatus::Tutorial(TutorialState::new(
"rules".to_string(),
utils::includes::rules(),
utils::includes::rules(outer.launched_at_day),
ui.ctx(),
outer.map_texture.clone(),
&outer.theme,
Expand Down
2 changes: 1 addition & 1 deletion truncate_client/src/regions/native_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn render_native_menu_if_required(
if ui.button("Tutorial: Rules").clicked() {
return Some(GameStatus::Tutorial(TutorialState::new(
"rules".to_string(),
utils::includes::rules(),
utils::includes::rules(outer.launched_at_day),
ui.ctx(),
outer.map_texture.clone(),
&outer.theme,
Expand Down
15 changes: 12 additions & 3 deletions truncate_client/src/utils/includes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ pub enum ChangePriority {
Low,
}

pub fn rules() -> Tutorial {
serde_yaml::from_slice(include_bytes!("../../tutorials/rules.yml"))
.expect("Tutorial should match Tutorial format")
pub fn rules(for_day: u32) -> Tutorial {
[
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_2.yml"))
.expect("Tutorial should match Tutorial format"),
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_1.yml"))
.expect("Tutorial should match Tutorial format"),
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_0.yml"))
.expect("Tutorial should match Tutorial format"),
]
.into_iter()
.find(|r| r.effective_day <= for_day || r.effective_day == 0)
.expect("Some ruleset should apply for any given day")
}

pub fn changelogs() -> HashMap<&'static str, Tutorial> {
Expand Down
Loading

0 comments on commit 2248d33

Please sign in to comment.