diff --git a/server/src/game.rs b/server/src/game.rs index 7afded3..fbb9d3e 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -148,9 +148,13 @@ impl Game { tracing::debug!("Player is czar"); Err("You can't submit cards to judge, you ARE the judge!".to_string()) } else { + // Error if not enough cards + if request.card_ids.len() < self.current_black.pick.into() { + return Err("You didn't pick enough cards!".to_string()); + } + // Ignore extra cards let trimmed = request.card_ids[..self.current_black.pick.into()].to_vec(); - // TODO: handle not enough cards tracing::debug!("Trimmed: {:#?}", trimmed); // Move card from player's hand to judge pile @@ -243,7 +247,7 @@ impl Game { tracing::debug!("{:#?}", self.rotation); tracing::debug!("{:#?}", self.rotation_index); // Choose new czar - if self.rotation_index == self.rotation.len() { + if self.rotation_index == self.rotation.len() - 1 { self.rotation_index = 0; } else { self.rotation_index += 1;