diff --git a/game/src/challenges.rs b/game/src/challenges.rs index 6657e70d93..2c76c51377 100644 --- a/game/src/challenges.rs +++ b/game/src/challenges.rs @@ -15,7 +15,7 @@ pub struct Challenge { pub description: Vec, pub alias: String, pub gameplay: GameplayMode, - pub cutscene: Option Box>, + pub cutscene: Option Box>, } // TODO Assuming the measurement is always maximizing time savings from a goal. @@ -35,7 +35,7 @@ impl Challenge { title: "Part 1".to_string(), description: vec!["Speed up one VIP's daily commute, at any cost!".to_string()], alias: "commute/pt1".to_string(), - gameplay: GameplayMode::OptimizeCommute(PersonID(1163), Duration::minutes(2)), + gameplay: GameplayMode::OptimizeCommute(PersonID(8819), Duration::minutes(2)), cutscene: Some( crate::sandbox::gameplay::commute::OptimizeCommute::cutscene_pt1, ), @@ -44,7 +44,10 @@ impl Challenge { title: "Part 2".to_string(), description: vec!["Speed up another VIP's commute".to_string()], alias: "commute/pt2".to_string(), - gameplay: GameplayMode::OptimizeCommute(PersonID(3434), Duration::minutes(5)), + gameplay: GameplayMode::OptimizeCommute( + PersonID(13121), + Duration::seconds(90.0), + ), cutscene: Some( crate::sandbox::gameplay::commute::OptimizeCommute::cutscene_pt2, ), @@ -266,7 +269,10 @@ impl Tab { Box::new(move |ctx, app| { let sandbox = Box::new(SandboxMode::new(ctx, app, challenge.gameplay.clone())); if let Some(cutscene) = challenge.cutscene { - Some(Transition::ReplaceThenPush(sandbox, cutscene(ctx, app))) + Some(Transition::ReplaceThenPush( + sandbox, + cutscene(ctx, app, &challenge.gameplay), + )) } else { Some(Transition::Replace(sandbox)) } diff --git a/game/src/cutscene.rs b/game/src/cutscene.rs index ef644afdbf..6d02439128 100644 --- a/game/src/cutscene.rs +++ b/game/src/cutscene.rs @@ -19,7 +19,7 @@ impl CutsceneBuilder { CutsceneBuilder { scenes: Vec::new() } } - pub fn scene(mut self, avatar: &str, msg: &str) -> CutsceneBuilder { + pub fn scene>(mut self, avatar: &str, msg: I) -> CutsceneBuilder { self.scenes.push(Scene { avatar: Some(avatar.to_string()), msg: Text::from(Line(msg)), @@ -27,7 +27,7 @@ impl CutsceneBuilder { self } - pub fn narrator(mut self, msg: &str) -> CutsceneBuilder { + pub fn narrator>(mut self, msg: I) -> CutsceneBuilder { self.scenes.push(Scene { avatar: None, msg: Text::from(Line(msg)), diff --git a/game/src/sandbox/gameplay/commute.rs b/game/src/sandbox/gameplay/commute.rs index c5f09b183b..2c707dc079 100644 --- a/game/src/sandbox/gameplay/commute.rs +++ b/game/src/sandbox/gameplay/commute.rs @@ -57,7 +57,11 @@ impl OptimizeCommute { }) } - pub fn cutscene_pt1(ctx: &mut EventCtx, app: &App) -> Box { + pub fn cutscene_pt1(ctx: &mut EventCtx, app: &App, mode: &GameplayMode) -> Box { + let goal = match mode { + GameplayMode::OptimizeCommute(_, d) => *d, + _ => unreachable!(), + }; CutsceneBuilder::new() .scene("boss", "Listen up, I've got a special job for you today.") .scene( @@ -94,14 +98,20 @@ impl OptimizeCommute { "The drone has been programmed to find the anonymous VIP. Watch their daily \ route, figure out what's wrong, and fix it.", ) - .narrator( + .narrator(format!( "Ignore the damage done to everyone else. Just speed up the VIP's trips by a \ - total of 2 minutes.", - ) + total of {}.", + goal + )) .build(ctx, app) } - pub fn cutscene_pt2(ctx: &mut EventCtx, app: &App) -> Box { + pub fn cutscene_pt2(ctx: &mut EventCtx, app: &App, mode: &GameplayMode) -> Box { + let goal = match mode { + GameplayMode::OptimizeCommute(_, d) => *d, + _ => unreachable!(), + }; + // TODO The person chosen for this currently has more of an issue needing PBLs, actually. CutsceneBuilder::new() .scene( "boss", @@ -127,10 +137,11 @@ impl OptimizeCommute { "Everyone's calling in favors these days. Just make it happen!", ) .narrator("Too many people have dirt on the boss. Guess we have another VIP to help.") - .narrator( + .narrator(format!( "Once again, ignore the damage to everyone else, and just speed up the VIP's \ - trips by a total of 5 minutes.", - ) + trips by a total of {}.", + goal + )) .build(ctx, app) } } @@ -196,7 +207,9 @@ impl GameplayState for OptimizeCommute { .0 .cutscene .unwrap())( - ctx, app + ctx, + app, + &GameplayMode::OptimizeCommute(self.person, self.goal), ))), false, ); @@ -416,7 +429,7 @@ impl State for FinalScore { (Challenge::find(self.next_mode.as_ref().unwrap()) .0 .cutscene - .unwrap())(ctx, app), + .unwrap())(ctx, app, self.next_mode.as_ref().unwrap()), ]), "Back to challenges" => { Transition::Clear(vec![main_menu(ctx, app), challenges_picker(ctx, app)]) diff --git a/sim/src/trips.rs b/sim/src/trips.rs index edb4c09569..3e95cc9269 100644 --- a/sim/src/trips.rs +++ b/sim/src/trips.rs @@ -751,7 +751,8 @@ impl TripManager { if self.active_trip_mode.get(&a) == Some(&id) { TripResult::Ok(a) } else { - panic!("{} should be ongoing, but no agent in active_trip_mode", id); + //panic!("{} should be ongoing, but no agent in active_trip_mode", id); + TripResult::ModeChange } }