From 06d3c82f365b80de2245ed40d3008a95249499cf Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 16 May 2023 19:20:55 +0300 Subject: [PATCH] feat(client): check for empty deck for a second time before drawing --- client/src/game_status/parser.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/game_status/parser.rs b/client/src/game_status/parser.rs index cfb269e..8ba5a77 100644 --- a/client/src/game_status/parser.rs +++ b/client/src/game_status/parser.rs @@ -136,9 +136,12 @@ fn parse_action(action: &Action, game: &Game, game_status: &mut GameStatus) { shuffle_discard_to_deck(target, action.seed.parse::().unwrap()); } - target - .hand - .push(target.deck.pop().unwrap_or_else(|| unreachable!())); + // NOTE: deck *might* still be empty, if discard was empty too + if !target.deck.is_empty() { + target + .hand + .push(target.deck.pop().unwrap_or_else(|| unreachable!())); + } } } Command::Discard { index } => { -- 2.44.1