summaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
authortslil clingman <>2020-01-19 15:44:43 -0800
committertslil clingman <>2020-01-19 15:44:43 -0800
commit4d18fad08c185e07d030f6574963ec6de8441ee5 (patch)
treeffec38b939318c2adbad7a9628efbfe0571633f7 /src/game.rs
parent3b9c74fa818026b7489a1ad0f8e122f9388d739a (diff)
reading string action entries works
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs18
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
}