1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::path::PathBuf;
use sc2_proto::sc2api;
use {FromProto, Result};
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone)]
pub enum GameResult {
Win,
Loss,
Tie,
Undecided,
}
#[derive(Debug, Copy, Clone)]
pub struct PlayerResult {
player_id: u32,
result: GameResult,
}
impl PlayerResult {
pub fn get_player_id(&self) -> u32 {
self.player_id
}
pub fn get_result(&self) -> GameResult {
self.result
}
}
impl FromProto<sc2api::Result> for GameResult {
fn from_proto(r: sc2api::Result) -> Result<GameResult> {
Ok(match r {
sc2api::Result::Victory => GameResult::Win,
sc2api::Result::Defeat => GameResult::Loss,
sc2api::Result::Tie => GameResult::Tie,
sc2api::Result::Undecided => GameResult::Undecided,
})
}
}
#[derive(Debug, Clone)]
pub enum Map {
LocalMap(PathBuf),
BlizzardMap(String),
}
#[derive(Debug, Clone)]
pub struct GameSetup {
map: Map,
}
impl GameSetup {
pub fn new(map: Map) -> Self {
Self { map: map }
}
pub fn get_map(&self) -> &Map {
&self.map
}
}