*self.bets.entry(username).or_default() += chips;
*self.committed.entry(username).or_default() += chips;
*self.stacks.entry(username).or_default() -= chips;
- self.active = self.seats.player_after_where(username, |username| self.in_hand.contains(&username));
self.state = State::PreFlopBetting;
if self.betting_round_completed() {
- self.state = State::DealingFlop;
+ self.advance_betting_round()?;
+ } else {
+ self.active = self.seats.player_after_where(username, |username| self.is_able_to_bet(username));
}
Ok(())
}
*self.stacks.entry(username).or_default() -= chips;
if self.betting_round_completed() {
self.advance_betting_round()?;
- } else { self.active = self.seats.player_after_where(username, |username| self.is_able_to_bet(username));
+ } else {
+ self.active = self.seats.player_after_where(username, |username| self.is_able_to_bet(username));
}
Ok(())
}
test_game(actions, settings, seed);
}
+
+ #[test]
+ fn very_small_stack_game() {
+ let actions = r#"[
+ {"timestamp":1685137578856,"username":"Peter","action":{"action":"Join","seat":0,"chips":7}},
+ {"timestamp":1685137605395,"username":"Geoff","action":{"action":"Join","seat":1,"chips":7}},
+ {"timestamp":1685137634338,"username":"Aga","action":{"action":"Join","seat":2,"chips":7}},
+ {"timestamp":1685137634339,"username":"Geoff","action":{"action":"NextToDeal"}},
+ {"timestamp":1685137634339,"username":"Aga","action":{"action":"ReceiveCard","card":{"rank":"Two","suit":"Spades"}}},
+ {"timestamp":1685137634339,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"Ace","suit":"Clubs"}}},
+ {"timestamp":1685137634340,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Jack","suit":"Spades"}}},
+ {"timestamp":1685137634340,"username":"Aga","action":{"action":"ReceiveCard","card":{"rank":"Seven","suit":"Spades"}}},
+ {"timestamp":1685137634340,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"Queen","suit":"Clubs"}}},
+ {"timestamp":1685137634341,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Five","suit":"Hearts"}}},
+ {"timestamp":1685137634341,"username":"Geoff","action":{"action":"EndDeal"}},
+ {"timestamp":1685137634341,"username":"Aga","action":{"action":"PostBlind","chips":7}},
+ {"timestamp":1685137634342,"username":"Peter","action":{"action":"PostBlind","chips":7}},
+ {"timestamp":1685137645517,"username":"Geoff","action":{"action":"Fold"}},
+ {"timestamp":1685137645518,"username":"Aga","action":{"action":"RevealCard","card":{"rank":"Two","suit":"Spades"}}},
+ {"timestamp":1685137645518,"username":"Aga","action":{"action":"RevealCard","card":{"rank":"Seven","suit":"Spades"}}},
+ {"timestamp":1685137645518,"username":"Peter","action":{"action":"RevealCard","card":{"rank":"Queen","suit":"Clubs"}}},
+ {"timestamp":1685137645519,"username":"Peter","action":{"action":"RevealCard","card":{"rank":"Ace","suit":"Clubs"}}},
+ {"timestamp":1685137645519,"username":"Geoff","action":{"action":"CommunityCard","card":{"rank":"Eight","suit":"Clubs"}}},
+ {"timestamp":1685137645519,"username":"Geoff","action":{"action":"CommunityCard","card":{"rank":"King","suit":"Spades"}}},
+ {"timestamp":1685137645519,"username":"Geoff","action":{"action":"CommunityCard","card":{"rank":"Seven","suit":"Clubs"}}},
+ {"timestamp":1685137645520,"username":"Geoff","action":{"action":"CommunityCard","card":{"rank":"Seven","suit":"Hearts"}}},
+ {"timestamp":1685137645520,"username":"Geoff","action":{"action":"CommunityCard","card":{"rank":"Nine","suit":"Clubs"}}},
+ {"timestamp":1685137645520,"username":"Peter","action":{"action":"WinHand","chips":14,"hand":"Flush, AQ987"}},
+ {"timestamp":1685137645520,"username":"Aga","action":{"action":"KnockedOut"}},
+ {"timestamp":1685137645521,"username":"Aga","action":{"action":"NextToDeal"}},
+ {"timestamp":1685137645521,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"Ten","suit":"Clubs"}}},
+ {"timestamp":1685137645521,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Three","suit":"Diamonds"}}},
+ {"timestamp":1685137645522,"username":"Peter","action":{"action":"ReceiveCard","card":{"rank":"Two","suit":"Spades"}}},
+ {"timestamp":1685137645522,"username":"Geoff","action":{"action":"ReceiveCard","card":{"rank":"Two","suit":"Diamonds"}}},
+ {"timestamp":1685137645523,"username":"Aga","action":{"action":"EndDeal"}},
+ {"timestamp":1685137645523,"username":"Peter","action":{"action":"PostBlind","chips":14}},
+ {"timestamp":1685137645523,"username":"Geoff","action":{"action":"PostBlind","chips":7}},
+ {"timestamp":1685137645523,"username":"Geoff","action":{"action":"RevealCard","card":{"rank":"Two","suit":"Diamonds"}}},
+ {"timestamp":1685137645524,"username":"Geoff","action":{"action":"RevealCard","card":{"rank":"Three","suit":"Diamonds"}}},
+ {"timestamp":1685137645524,"username":"Peter","action":{"action":"RevealCard","card":{"rank":"Two","suit":"Spades"}}},
+ {"timestamp":1685137645524,"username":"Peter","action":{"action":"RevealCard","card":{"rank":"Ten","suit":"Clubs"}}},
+ {"timestamp":1685137645524,"username":"Aga","action":{"action":"CommunityCard","card":{"rank":"Four","suit":"Diamonds"}}},
+ {"timestamp":1685137645525,"username":"Aga","action":{"action":"CommunityCard","card":{"rank":"Three","suit":"Clubs"}}},
+ {"timestamp":1685137645525,"username":"Aga","action":{"action":"CommunityCard","card":{"rank":"Five","suit":"Clubs"}}},
+ {"timestamp":1685137645525,"username":"Aga","action":{"action":"CommunityCard","card":{"rank":"Six","suit":"Clubs"}}},
+ {"timestamp":1685137645526,"username":"Aga","action":{"action":"CommunityCard","card":{"rank":"Ace","suit":"Clubs"}}},
+ {"timestamp":1685137645526,"username":"Peter","action":{"action":"WinHand","chips":21,"hand":"Flush, AT653"}},
+ {"timestamp":1685137645526,"username":"Geoff","action":{"action":"KnockedOut"}},
+ {"timestamp":1685137645526,"username":"Peter","action":{"action":"WinGame"}}
+ ]"#;
+
+ let actions = serde_json::from_str(actions).unwrap();
+
+ let settings = r#"{"format":"TexasHoldEm","title":"Quality Adventure","max_players":3,"small_blind":25,"starting_stack":7,"round_length":null,"tournament_length":null,"action_timeout":null,"start_time":null,"hide_cards":false}"#;
+ let settings = serde_json::from_str(settings).unwrap();
+
+ let seed = r#"{"rng":"ChaCha20","seed":"71358486a2dfd6efe046cc39d7a0f1b425caab7fe6ae92fa487c927783edbf5f"}"#;
+ let seed = serde_json::from_str(seed).unwrap();
+
+ test_game(actions, settings, seed);
+ }
}