1pub mod point;
2pub mod utils;
3
4pub use bk2d_macro::*;
5
6use point::*;
7
8pub trait Action {
9 fn name(&self) -> &'static str;
10
11 fn stage(&self) -> u32;
12}
13
14pub trait Public {
15 fn round(&self) -> u32;
16
17 fn id(&self) -> u64;
18}
19
20pub trait BK2D {
21 type Error: std::error::Error;
22 type Player: Player;
23 type Action: Action + Clone;
24 type ActionResult;
25 type Public: Public + Clone;
26 type Options: std::default::Default;
27
28 fn new(board: Board, options: Self::Options) -> Self;
29
30 fn add_player(&mut self, p: Self::Player) -> Result<(), Self::Error>;
31
32 fn current_player(&self) -> &<Self::Player as Player>::Ident;
33
34 fn next_player(&mut self) -> &<Self::Player as Player>::Ident;
35
36 fn start(&mut self);
37
38 fn action(&mut self, action: Self::Action) -> Result<Self::ActionResult, Self::Error>;
39
40 fn is_start(&self) -> bool;
41
42 fn round(&self) -> u32;
43
44 fn public_actions(&self, round: Option<u32>) -> &[Self::Public];
45
46 fn public_actions_from(&self, start: u64, end: Option<u64>) -> &[Self::Public];
47
48 fn win(&self) -> Option<&<Self::Player as Player>::Ident>;
49}
50
51pub trait Player {
52 type Ident;
53
54 fn ident(&self) -> &Self::Ident;
55 fn location(&self) -> &Point;
56}
57
58#[cfg(test)]
59mod tests;