From 4d18fad08c185e07d030f6574963ec6de8441ee5 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Sun, 19 Jan 2020 15:44:43 -0800 Subject: reading string action entries works --- src/game.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/game.rs') diff --git a/src/game.rs b/src/game.rs index e05a807..931a15f 100644 --- a/src/game.rs +++ b/src/game.rs @@ -188,12 +188,30 @@ impl GameState { // Unconditional and so could lead to invalid state, but private fn place_stone(&self, player: Player, pos: &Position, stone: Stone) -> GameState { + // Place stone let mut copy = self.copy(); let idx = self.pos_to_idx(&pos); copy.board[idx].push(Piece { player: player, stone: stone, }); + // Decrease count + match player { + Player::Black => { + if stone == Stone::Capstone { + copy.black_capstones -= 1; + } else { + copy.black_flats -= 1; + } + } + Player::White => { + if stone == Stone::Capstone { + copy.white_capstones -= 1; + } else { + copy.white_flats -= 1; + } + } + } copy } -- cgit v1.3.1