Skip to content

Commit 80e313c

Browse files
authored
Merge pull request #288 from TruncateGame/fix/latent-changelog
Resolve latent release state loading newer tutorial
2 parents 0ef788a + 2248d33 commit 80e313c

File tree

6 files changed

+923
-6
lines changed

6 files changed

+923
-6
lines changed

truncate_client/src/handle_launch_code.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn handle_launch_code(
4040
"TUTORIAL_RULES" => {
4141
return Some(GameStatus::Tutorial(TutorialState::new(
4242
"rules".to_string(),
43-
utils::includes::rules(),
43+
utils::includes::rules(outer.launched_at_day),
4444
ui.ctx(),
4545
outer.map_texture.clone(),
4646
&outer.theme,

truncate_client/src/regions/native_menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn render_native_menu_if_required(
3838
if ui.button("Tutorial: Rules").clicked() {
3939
return Some(GameStatus::Tutorial(TutorialState::new(
4040
"rules".to_string(),
41-
utils::includes::rules(),
41+
utils::includes::rules(outer.launched_at_day),
4242
ui.ctx(),
4343
outer.map_texture.clone(),
4444
&outer.theme,

truncate_client/src/utils/includes.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,18 @@ pub enum ChangePriority {
5252
Low,
5353
}
5454

55-
pub fn rules() -> Tutorial {
56-
serde_yaml::from_slice(include_bytes!("../../tutorials/rules.yml"))
57-
.expect("Tutorial should match Tutorial format")
55+
pub fn rules(for_day: u32) -> Tutorial {
56+
[
57+
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_2.yml"))
58+
.expect("Tutorial should match Tutorial format"),
59+
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_1.yml"))
60+
.expect("Tutorial should match Tutorial format"),
61+
serde_yaml::from_slice::<Tutorial>(include_bytes!("../../tutorials/rules_0.yml"))
62+
.expect("Tutorial should match Tutorial format"),
63+
]
64+
.into_iter()
65+
.find(|r| r.effective_day <= for_day || r.effective_day == 0)
66+
.expect("Some ruleset should apply for any given day")
5867
}
5968

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

0 commit comments

Comments
 (0)