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
mod board;
mod coord;
mod direction;
mod piece;
mod state;
use thiserror::Error;
pub use board::Board;
pub use coord::Coord;
pub use direction::Direction;
pub use piece::Piece;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
pub use state::Thud;
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum Player {
Dwarf,
Troll,
}
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum EndState {
Won(Player),
Draw,
}
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Copy, Clone, Error)]
pub enum ThudError {
#[error("({0},{1}) is out of bounds")]
InvalidPosition(usize, usize),
#[error("Requested move not allowed")]
IllegalMove,
#[error("A piece at ({0},{1}) is blocking that move")]
Obstacle(usize, usize),
#[error("You need {0} pieces behind you to make that move but you only have {1}")]
LineTooShort(usize, usize),
#[error("Arithmetic Error")]
MathError,
#[error("Action not allowed at this point in the game")]
BadAction,
}