diff options
Diffstat (limited to 'src/game.rs')
| -rw-r--r-- | src/game.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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 } |
