Allow modding the experiment, and fix the --dev unlock_all functionality

This commit is contained in:
Dustin Carlino 2020-12-19 15:12:36 -08:00
parent 6642c6e1a9
commit ab92a387f2
2 changed files with 10 additions and 11 deletions

View File

@ -49,7 +49,7 @@ impl Level {
time_limit: Duration::seconds(90.0),
goal: 25,
unlock_upzones: 2,
unlock_upzones: 1,
unlock_vehicles: vec!["cargo bike".to_string()],
},
// TODO Super dense, starting point isn't even near apartments, run out of gifts after
@ -66,7 +66,7 @@ impl Level {
time_limit: Duration::seconds(90.0),
goal: 25,
unlock_upzones: 2,
unlock_upzones: 1,
unlock_vehicles: vec![],
},
Level {
@ -81,7 +81,7 @@ impl Level {
time_limit: Duration::minutes(3),
goal: 1000,
unlock_upzones: 2,
unlock_upzones: 1,
unlock_vehicles: vec![],
},
Level {
@ -96,7 +96,7 @@ impl Level {
time_limit: Duration::minutes(5),
goal: 1000,
unlock_upzones: 3,
unlock_upzones: 1,
unlock_vehicles: vec![],
},
Level {
@ -122,7 +122,7 @@ impl Level {
time_limit: Duration::minutes(5),
goal: 1000,
unlock_upzones: 3,
unlock_upzones: 5,
unlock_vehicles: vec![],
},
]

View File

@ -48,13 +48,10 @@ impl Session {
abstutil::path_player("santa.json"),
&mut Timer::throwaway(),
) {
// TODO Explicit version number to detect more easily?
if session.levels == levels {
return session;
if session.levels != levels {
warn!("Using modified levels from the session data");
}
// TODO Try to preserve high scores or levels unlocked? It could get complicated,
// depending on how levels were changed or reordered.
warn!("Loaded session data, but the levels have changed, so discarding!");
return session;
}
let mut high_scores = HashMap::new();
@ -131,11 +128,13 @@ impl Session {
}
pub fn unlock_all(&mut self) {
self.upzones_unlocked = 0;
for level in &self.levels {
self.vehicles_unlocked.extend(level.unlock_vehicles.clone());
self.upzones_unlocked += level.unlock_upzones;
}
self.levels_unlocked = self.levels.len();
self.upzones_explained = true;
}
pub fn update_music(&mut self, ctx: &mut EventCtx) {