diff --git a/src/bin/bevy.rs b/src/bin/bevy.rs index 2b0539b..190c368 100644 --- a/src/bin/bevy.rs +++ b/src/bin/bevy.rs @@ -219,6 +219,12 @@ impl Game { self.cursor_x = x.clamp(0, self.sim.map.width - 1); self.cursor_y = y.clamp(0, self.sim.map.height - 1); } + /// Attendance follows the cursor (day-job.md criterion 7): the job + /// runs attended exactly while the cursor sits on the host rack. + fn sync_attendance(&mut self) { + let on_host = (self.cursor_x, self.cursor_y) == self.sim.core_position(); + self.sim.set_attended(on_host); + } fn add_log(&mut self, tick: u64, msg: &str) { self.log.push((tick, msg.to_string())); let n = self.log.len(); @@ -667,6 +673,8 @@ fn handle_input( if kb.just_pressed(KeyCode::KeyQ) { exit.write(AppExit::Success); } + // Cursor moves above may have landed on / left the host rack. + game.sync_attendance(); game.drain(); } @@ -838,6 +846,11 @@ fn advance_sim(time: Res