summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2020-04-25 11:49:11 +0200
committerJustin Wernick <justin@worthe-it.co.za>2020-04-25 11:49:11 +0200
commitbcd5a626c2f8cf0d4ea76c7d1ad50744a0753c03 (patch)
treec0bd5a29bc398f2c82df913335c6430237a5e9de
parent52ade984643c6482ccf0deeea98f7f63fa74045d (diff)
Skeleton of supporting update publishing events
-rw-r--r--src/state.rs23
1 files 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<u16>,
+}
+
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) {