Skip to main content

nmm_lib/
game_move.rs

1use Player;
2use Location;
3
4#[macro_export]
5macro_rules! game_move {
6    ($player:ident, $from:ident, $to:ident) 
7        => (GameMove::new(Player::$player, Location::$from, Location::$to, None));
8    ($player:ident, $from:ident, $to:ident, $remove:ident)
9        => (GameMove::new(Player::$player, Location::$from, Location::$to, Some(Location::$remove)));
10}
11
12#[derive(PartialEq, Debug, Clone)]
13pub struct GameMove {
14    player: Player,
15    from: Location,
16    to: Location,
17    remove: Option<Location>
18}
19
20impl GameMove {
21    pub fn new(player: Player, from: Location, to: Location, remove: Option<Location>) -> GameMove {
22        GameMove {
23            player,
24            from,
25            to,
26            remove
27        }
28    }
29
30    pub fn get_player(&self) -> Player {
31        self.player
32    }
33
34    pub fn get_from(&self) -> Location {
35        self.from
36    }
37
38    pub fn get_to(&self) -> Location {
39        self.to
40    }
41
42    pub fn get_remove(&self) -> Option<Location> {
43        self.remove
44    }
45}