Cleaned up unused structures, and added fields to structures that didn't have them
parent
38cfa8e932
commit
2b30e64c14
71
src/main.rs
71
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<String>,
|
||||
}
|
||||
|
||||
#[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<GameState>,
|
||||
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<i32, Division>,
|
||||
field_sets: HashMap<i32, FieldSet>,
|
||||
rankings: Vec<Rank>,
|
||||
}
|
||||
|
||||
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<DivisionState>,
|
||||
matches: Vec<Match>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
struct FieldSet {
|
||||
fields: Vec<Field>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
struct Field {
|
||||
name: String,
|
||||
id: i32,
|
||||
last_known_match: Option<MatchTuple>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
struct MatchState {
|
||||
state: Option<GameState>,
|
||||
start_s: Option<u32>,
|
||||
start_ns: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
struct MatchInfo {
|
||||
red_teams: [String; 2],
|
||||
blue_teams: [String; 2],
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
struct Match {
|
||||
state: Option<MatchState>,
|
||||
info: Option<MatchInfo>,
|
||||
match_tuple: MatchTuple,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue