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"));
|
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)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
enum GameSide {
|
enum GameSide {
|
||||||
Red,
|
Red,
|
||||||
|
|
@ -65,7 +54,7 @@ struct GameScore {
|
||||||
blue_total: i32,
|
blue_total: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
enum GameState {
|
enum GameState {
|
||||||
Scheduled,
|
Scheduled,
|
||||||
Timeout,
|
Timeout,
|
||||||
|
|
@ -76,13 +65,6 @@ enum GameState {
|
||||||
Abandoned,
|
Abandoned,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct ArenaStateInfo {
|
|
||||||
state: Option<GameState>,
|
|
||||||
start_s: usize,
|
|
||||||
start_ns: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||||
enum Round {
|
enum Round {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
@ -129,28 +111,30 @@ struct MatchTuple {
|
||||||
session: i32,
|
session: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
struct ArenaInfo {
|
|
||||||
red_teams: [String; 2],
|
|
||||||
blue_teams: [String; 2],
|
|
||||||
match_tuple: MatchTuple,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MQTTMessage {
|
struct MQTTMessage {
|
||||||
topic: String,
|
topic: String,
|
||||||
payload: String,
|
payload: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
struct Rank {
|
||||||
|
team: String,
|
||||||
|
rank: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
struct Event {
|
struct Event {
|
||||||
divisions: HashMap<i32, Division>,
|
divisions: HashMap<i32, Division>,
|
||||||
field_sets: HashMap<i32, FieldSet>,
|
field_sets: HashMap<i32, FieldSet>,
|
||||||
|
rankings: Vec<Rank>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event {
|
impl Event {
|
||||||
fn new() -> Event {
|
fn new() -> Event {
|
||||||
Event{
|
Event{
|
||||||
|
rankings: Vec::new(),
|
||||||
divisions: HashMap::new(),
|
divisions: HashMap::new(),
|
||||||
field_sets: HashMap::new(),
|
field_sets: HashMap::new(),
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +161,7 @@ impl Event {
|
||||||
for division in division_list.divisions {
|
for division in division_list.divisions {
|
||||||
self.divisions.insert(division.id() as i32, Division{
|
self.divisions.insert(division.id() as i32, Division{
|
||||||
name: String::from(division.name()),
|
name: String::from(division.name()),
|
||||||
|
state: None,
|
||||||
matches: Vec::new(),
|
matches: Vec::new(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -195,12 +180,16 @@ impl Event {
|
||||||
match matches.get_mut(&match_tuple.division) {
|
match matches.get_mut(&match_tuple.division) {
|
||||||
Some(match_list) => {
|
Some(match_list) => {
|
||||||
match_list.push(Match{
|
match_list.push(Match{
|
||||||
|
state: None,
|
||||||
|
info: None,
|
||||||
match_tuple: match_tuple.clone(),
|
match_tuple: match_tuple.clone(),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let mut new_match_list = Vec::new();
|
let mut new_match_list = Vec::new();
|
||||||
new_match_list.push(Match{
|
new_match_list.push(Match{
|
||||||
|
state: None,
|
||||||
|
info: None,
|
||||||
match_tuple: match_tuple.clone(),
|
match_tuple: match_tuple.clone(),
|
||||||
});
|
});
|
||||||
matches.insert(match_tuple.division, new_match_list);
|
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 {
|
struct Division {
|
||||||
name: String,
|
name: String,
|
||||||
|
state: Option<DivisionState>,
|
||||||
matches: Vec<Match>,
|
matches: Vec<Match>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
struct FieldSet {
|
struct FieldSet {
|
||||||
fields: Vec<Field>,
|
fields: Vec<Field>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
struct Field {
|
struct Field {
|
||||||
name: String,
|
name: String,
|
||||||
id: i32,
|
id: i32,
|
||||||
last_known_match: Option<MatchTuple>,
|
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)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
struct Match {
|
struct Match {
|
||||||
|
state: Option<MatchState>,
|
||||||
|
info: Option<MatchInfo>,
|
||||||
match_tuple: MatchTuple,
|
match_tuple: MatchTuple,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue