From bcd5a626c2f8cf0d4ea76c7d1ad50744a0753c03 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Sat, 25 Apr 2020 11:49:11 +0200 Subject: Skeleton of supporting update publishing events --- src/state.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/state.rs b/src/state.rs index 25594a0..0a5fd71 100644 --- a/src/state.rs +++ b/src/state.rs @@ -37,11 +37,25 @@ pub struct Position { pub x: u16, } +#[derive(Debug, Clone, Default)] +pub struct GameStateUpdateEvents { + pub players: [GameStatePlayerUpdateEvents; 2], +} +#[derive(Debug, Clone, Default)] +pub struct GameStatePlayerUpdateEvents { + pub boosts_collected: u16, + pub boosts_used: u16, + pub boosts_maintained: u8, + pub mud_hit: u16, + pub oil_collected: u16, + pub distance_travelled: u16, + pub rounds_to_finish: Option, +} + impl GameState { - // TODO: Return metadata on what each bot did from this - pub fn update(&mut self, commands: [Command; 2]) { + pub fn update(&mut self, commands: [Command; 2]) -> GameStateUpdateEvents { if self.status != GameStatus::Continue { - return; + return GameStateUpdateEvents::default(); } let next_positions = [ @@ -66,6 +80,9 @@ impl GameState { } else { GameStatus::Continue }; + + // TODO + GameStateUpdateEvents::default() } pub fn reset_players_to_start(&mut self) { -- cgit v1.2.3