From ffe49ad1ee755c4d3ac4b3ecb0532a8afd0d889c Mon Sep 17 00:00:00 2001 From: BakerNet Date: Tue, 4 Jun 2024 22:44:13 -0700 Subject: [PATCH] Updated wrong flag logic in db9c16f --- minesweeper-lib/src/game.rs | 2 +- web/src/app/minesweeper/client.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minesweeper-lib/src/game.rs b/minesweeper-lib/src/game.rs index 85b0ee6..c6e4d61 100644 --- a/minesweeper-lib/src/game.rs +++ b/minesweeper-lib/src/game.rs @@ -131,7 +131,7 @@ impl Minesweeper { fn handle_flag(&mut self, player: usize, cell_point: BoardPoint) -> Result { let (_, cell_state) = &self.board[cell_point]; if cell_state.revealed { - return Ok(PlayOutcome::Success(Vec::new())); + bail!("Tried to play already revealed cell") } let player_cell = if self.players[player].flags.contains(&cell_point) { self.players[player].flags.remove(&cell_point); diff --git a/web/src/app/minesweeper/client.rs b/web/src/app/minesweeper/client.rs index 654652a..ed5922c 100644 --- a/web/src/app/minesweeper/client.rs +++ b/web/src/app/minesweeper/client.rs @@ -184,7 +184,7 @@ impl FrontendGame { let player = self.play_protections()?; let game: &MinesweeperClient = &(*self.game).borrow(); if let PlayerCell::Revealed(_) = game.board[BoardPoint { row, col }] { - bail!("Tried to flag revealed cell") + return Ok(()); } let play_json = serde_json::to_string(&Play { player,