gn_communicator/
models.rs1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub enum MatchError {
8 AllPlayersDisconnected,
9 PlayerDidNotJoin(String),
10}
11
12#[derive(Debug, Clone, Deserialize, Serialize)]
13pub struct MatchAbrubtClose {
14 pub match_id: String,
15 pub reason: MatchError,
16}
17
18
19#[derive(Deserialize, Debug, Clone, Serialize)]
20pub struct MatchResult {
21 pub match_id: String,
22 pub winners: HashMap<String, u8>,
23 pub losers: HashMap<String, u8>,
24 pub ranking: Ranking,
25 pub event_log: Vec<Value>
26}
27
28#[derive(Deserialize, Debug, Clone, Serialize)]
29pub struct Ranking {
30 pub performances: HashMap<String, Vec<String>>,
31}
32
33#[derive(Deserialize, Debug, Serialize)]
34pub struct CreatedMatch {
35 pub region: String,
36 pub player_write: HashMap<String, String>,
37 pub game: String,
38 pub mode: String,
39 pub ai_players: Vec<String>,
40 pub read: String,
41 pub url_pub: String,
42 pub url_priv: String,
43}
44
45#[derive(Deserialize, Debug, Clone, Serialize)]
46pub struct GameServerCreate {
47 pub region: String,
48 pub game: String,
49 pub mode: String,
50 pub min_players: u32,
51 pub max_players: u32,
52 pub server_pub: String,
53 pub server_priv: String,
54 pub ranking_conf: RankingConf,
55}
56
57#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
58pub struct RankingConf {
59 pub max_stars: i32,
60 pub description: String,
61 pub performances: Vec<Performance>,
62}
63
64#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
65pub struct Performance {
66 pub name: String,
67 pub weight: i32,
68}
69
70
71#[derive(Deserialize, Debug, Clone, Serialize)]
72pub struct CreateMatch {
73 pub game: String,
74 pub players: Vec<String>,
75 pub ai_players: Vec<String>,
76 pub mode: String,
77}
78
79#[derive(Deserialize, Debug, Clone, Serialize)]
80pub struct AIPlayerRegister {
81 pub game: String,
82 pub mode: String,
83 pub elo: u32,
84 pub display_name: String
85}
86
87#[derive(Serialize)]
88pub struct Task {
89 pub ai_id: String,
90 pub game: String,
91 pub mode: String,
92 pub address: String,
93 pub read: String,
94 pub write: String,
95 pub players: Vec<String>
96}