From: Geoffrey Allott Date: Wed, 14 Jun 2023 10:37:43 +0000 (+0100) Subject: deal 5 cards for 3 and 4-player cribbage X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=2571f4746e94fa09336c27623e833315f2c9b0f6;p=pokerwave.git deal 5 cards for 3 and 4-player cribbage --- diff --git a/src/game/cribbage/.mod.rs.swp b/src/game/cribbage/.mod.rs.swp new file mode 100644 index 0000000..fd2e403 Binary files /dev/null and b/src/game/cribbage/.mod.rs.swp differ diff --git a/src/game/cribbage/mod.rs b/src/game/cribbage/mod.rs index fc7dcee..e4e68fc 100644 --- a/src/game/cribbage/mod.rs +++ b/src/game/cribbage/mod.rs @@ -100,7 +100,13 @@ impl Cribbage { } fn all_hands_dealt(&self) -> bool { - self.hands.values().map(CardSet::len).all(|len| len == 6) + let hand_size = match self.hands.len() { + 2 => 6, + 3 => 5, + 4 => 5, + _ => 6, + }; + self.hands.values().map(CardSet::len).all(|len| len == hand_size) } fn pegging_total(&self) -> u32 { @@ -2292,10 +2298,7 @@ mod tests { {"timestamp":1686202533322,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"King","suit":"Clubs"}}}, {"timestamp":1686202533322,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Six","suit":"Clubs"}}}, {"timestamp":1686202533323,"username":"Aga","action":{"action":"ReceiveCard","card":{"rank":"Four","suit":"Diamonds"}}}, - {"timestamp":1686202533323,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"Ten","suit":"Clubs"}}}, - {"timestamp":1686202533323,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Nine","suit":"Diamonds"}}}, - {"timestamp":1686202533324,"username":"Aga","action":{"action":"ReceiveCard","card":{"rank":"Ace","suit":"Hearts"}}}, - {"timestamp":1686202533324,"username":"Aga","action":{"action":"DealBox","card":{"rank":"Nine","suit":"Clubs"}}}, + {"timestamp":1686202533324,"username":"Aga","action":{"action":"DealBox","card":{"rank":"Ten","suit":"Clubs"}}}, {"timestamp":1686202533324,"username":"Aga","action":{"action":"EndDeal"}} ]"#;