diff --git a/src/main.rs b/src/main.rs index 23b5e76..3e831cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,17 +28,6 @@ pub mod tm { include!(concat!(env!("OUT_DIR"), "/tm.rs")); } -#[derive(Serialize, Deserialize, Debug)] -struct DivisionInfo { - arena: String, - game_id: String, -} - -#[derive(Serialize, Deserialize, Debug)] -struct DivisionRankingInfo { - rankings: Vec, -} - #[derive(Serialize, Deserialize, Debug)] enum GameSide { Red, @@ -65,7 +54,7 @@ struct GameScore { blue_total: i32, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] enum GameState { Scheduled, Timeout, @@ -76,13 +65,6 @@ enum GameState { Abandoned, } -#[derive(Serialize, Deserialize, Debug)] -struct ArenaStateInfo { - state: Option, - start_s: usize, - start_ns: usize, -} - #[derive(Serialize, Deserialize, Debug, Clone, Copy)] enum Round { None = 0, @@ -129,28 +111,30 @@ struct MatchTuple { session: i32, } -#[derive(Serialize, Deserialize, Debug)] -struct ArenaInfo { - red_teams: [String; 2], - blue_teams: [String; 2], - match_tuple: MatchTuple, -} - #[derive(Debug)] struct MQTTMessage { topic: String, payload: String, } -#[derive(Debug, Clone)] + +#[derive(Serialize, Deserialize, Debug, Clone)] +struct Rank { + team: String, + rank: i32, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] struct Event { divisions: HashMap, field_sets: HashMap, + rankings: Vec, } impl Event { fn new() -> Event { Event{ + rankings: Vec::new(), divisions: HashMap::new(), field_sets: HashMap::new(), } @@ -177,6 +161,7 @@ impl Event { for division in division_list.divisions { self.divisions.insert(division.id() as i32, Division{ name: String::from(division.name()), + state: None, matches: Vec::new(), }); } @@ -195,12 +180,16 @@ impl Event { match matches.get_mut(&match_tuple.division) { Some(match_list) => { match_list.push(Match{ + state: None, + info: None, match_tuple: match_tuple.clone(), }) }, None => { let mut new_match_list = Vec::new(); new_match_list.push(Match{ + state: None, + info: None, match_tuple: match_tuple.clone(), }); matches.insert(match_tuple.division, new_match_list); @@ -216,26 +205,48 @@ impl Event { } } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] +struct DivisionState { + current_arena: u32, + current_match: MatchTuple, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] struct Division { name: String, + state: Option, matches: Vec, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] struct FieldSet { fields: Vec, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] struct Field { name: String, id: i32, last_known_match: Option, } +#[derive(Serialize, Deserialize, Debug, Clone)] +struct MatchState { + state: Option, + start_s: Option, + start_ns: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +struct MatchInfo { + red_teams: [String; 2], + blue_teams: [String; 2], +} + #[derive(Serialize, Deserialize, Debug, Clone)] struct Match { + state: Option, + info: Option, match_tuple: MatchTuple, }