summaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
authortslil clingman <>2020-02-01 11:42:12 -0800
committertslil clingman <>2020-02-01 11:42:12 -0800
commit8413caf1d6429bade43a90e4b8d4a662f0fd7deb (patch)
treea36e52e395c071c5865839d66e8377b6d6a22499 /src/game.rs
parent10f615418ebc5cf4a12b82bbcb95a74cbde8c339 (diff)
Features complete for v 0.1.0
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/game.rs b/src/game.rs
index 8716111..2745073 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -112,6 +112,7 @@ pub struct Piece {
#[derive(Clone, Copy)]
pub enum WinType {
+ Dragon,
RoadWin(Player),
FlatWin(Player),
Draw,
@@ -127,6 +128,7 @@ impl fmt::Display for WinType {
WinType::RoadWin(Player::White) => "R-0",
WinType::FlatWin(Player::Black) => "0-F",
WinType::FlatWin(Player::White) => "F-0",
+ WinType::Dragon => "R-R",
WinType::Draw => "1/2-1/2",
}
)
@@ -606,19 +608,17 @@ impl GameState {
}
}
- if self.dfs(Player::Black, true, todo_black_up)
- || self.dfs(Player::Black, false, todo_black_right)
- {
- return Some(WinType::RoadWin(Player::Black));
- }
+ let black_road = self.dfs(Player::Black, true, todo_black_up)
+ || self.dfs(Player::Black, false, todo_black_right);
+ let white_road = self.dfs(Player::White, true, todo_white_up)
+ || self.dfs(Player::White, false, todo_white_right);
- if self.dfs(Player::White, true, todo_white_up)
- || self.dfs(Player::White, false, todo_white_right)
- {
- return Some(WinType::RoadWin(Player::White));
+ match (black_road, white_road) {
+ (false, false) => return None,
+ (true, false) => return Some(WinType::RoadWin(Player::Black)),
+ (false, true) => return Some(WinType::RoadWin(Player::White)),
+ (true, true) => return Some(WinType::Dragon),
}
-
- return None;
}
fn check_flat_win(&self) -> Option<WinType> {
@@ -651,7 +651,6 @@ impl GameState {
return None;
}
- // TODO: this does not handle the case dragon edge case
fn check_win(&self) -> Option<WinType> {
if let Some(w) = self.check_road_win() {
return Some(w);
@@ -667,6 +666,25 @@ enum TurnOrder {
Normal,
}
+/*
+pub enum StartType {
+ CPS(u8),
+ FCS,
+ TPS,
+ CZS,
+}
+
+impl TurnOrder {
+ pub fn next_turn(&self, turn_num: usize, st: StartType) {
+ match st {
+ StartType::CPS(c) => {
+
+ }
+ }
+ }
+}
+*/
+
pub struct Game {
size: u8,
current_player: Player,
@@ -746,6 +764,10 @@ impl Game {
self.size
}
+ pub fn get_date_string(&self) -> &str {
+ &self.date_string
+ }
+
pub fn query_action_lines(&self) -> Vec<String> {
let mut result = Vec::new();
let mut newline = true;