def test_returns_winners_for_tied_pair(self): players = [Player(), Player()] game = Game(players) game.community.append(Card(suit=Suit.CLUB, number = 12)) game.community.append(Card(suit=Suit.DIAMOND, number = 12)) game.community.append(Card(suit=Suit.SPADE, number = 11)) game.community.append(Card(suit=Suit.HEART, number = 11)) game.community.append(Card(suit=Suit.DIAMOND, number = 11)) player1 = game.players[0] player1.hand.append(Card(suit=Suit.DIAMOND, number = 14)) player1.hand.append(Card(suit=Suit.DIAMOND, number = 3)) player2 = game.players[1] player2.hand.append(Card(suit=Suit.CLUB, number = 14)) player2.hand.append(Card(suit=Suit.DIAMOND, number = 5)) players = [player1, player2] game.set_player_hands() winners = game.break_tie(players) self.assertTrue(player1 in winners) self.assertTrue(player2 in winners) self.assertEqual(player1.best_hand['score'], Hand.FULL_HOUSE) self.assertEqual(player2.best_hand['score'], Hand.FULL_HOUSE)
def test_flush_breaker_returns_single_player(self): players = [Player(), Player(), Player()] game = Game(players) game.community.append(Card(suit=Suit.CLUB, number = 8)) game.community.append(Card(suit=Suit.CLUB, number = 14)) game.community.append(Card(suit=Suit.CLUB, number = 9)) game.community.append(Card(suit=Suit.CLUB, number = 10)) game.community.append(Card(suit=Suit.CLUB, number = 13)) player1 = game.players[0] player1.hand.append(Card(suit=Suit.CLUB, number = 2)) player1.hand.append(Card(suit=Suit.CLUB, number = 14)) player2 = game.players[1] player2.hand.append(Card(suit=Suit.CLUB, number = 4)) player2.hand.append(Card(suit=Suit.CLUB, number = 5)) player3 = game.players[2] player3.hand.append(Card(suit=Suit.CLUB, number = 6)) player3.hand.append(Card(suit=Suit.DIAMOND, number = 7)) players = [player1, player2, player3] game.set_player_hands() winners = game.break_tie(players) self.assertTrue(player1 in winners) self.assertFalse(player2 in winners) self.assertFalse(player3 in winners) self.assertEqual(player1.best_hand['score'], Hand.FLUSH) self.assertEqual(player2.best_hand['score'], Hand.FLUSH) self.assertEqual(player3.best_hand['score'], Hand.FLUSH)
def test_returns_tie_for_straights(self): players = [Player(), Player()] game = Game(players) game.community.append(Card(suit=Suit.CLUB, number = 9)) game.community.append(Card(suit=Suit.CLUB, number = 10)) game.community.append(Card(suit=Suit.CLUB, number = 11)) game.community.append(Card(suit=Suit.CLUB, number = 12)) game.community.append(Card(suit=Suit.DIAMOND, number = 13)) player1 = game.players[0] player1.hand.append(Card(suit=Suit.DIAMOND, number = 2)) player1.hand.append(Card(suit=Suit.DIAMOND, number = 3)) player2 = game.players[1] player2.hand.append(Card(suit=Suit.DIAMOND, number = 4)) player2.hand.append(Card(suit=Suit.DIAMOND, number = 5)) players = [player1, player2] game.set_player_hands() winners = game.break_tie(players) self.assertTrue(player1 in winners) self.assertTrue(player2 in winners) self.assertEqual(player1.best_hand['score'], Hand.STRAIGHT) self.assertEqual(player2.best_hand['score'], Hand.STRAIGHT)
def test_get_winning_player_returns_both_players_with_true_tie(self): players = [Player(), Player()] game = Game(players) #community cards game.community.append(Card(suit=Suit.CLUB, number=2)) game.community.append(Card(suit=Suit.DIAMOND, number=11)) game.community.append(Card(suit=Suit.SPADE, number=5)) game.community.append(Card(suit=Suit.HEART, number=6)) game.community.append(Card(suit=Suit.DIAMOND, number=7)) #player1 cards player1 = game.players[0] player1.hand.append(Card(suit=Suit.CLUB, number=8)) player1.hand.append(Card(suit=Suit.CLUB, number=9)) #player2 cards player2 = game.players[1] player2.hand.append(Card(suit=Suit.DIAMOND, number=8)) player2.hand.append(Card(suit=Suit.DIAMOND, number=9)) game.set_player_hands() winners = game.get_winning_player() self.assertTrue(player1 in winners) self.assertTrue(player2 in winners)
def test_get_winning_player_returns_player1_with_tie(self): players = [Player(), Player()] game = Game(players) #community cards game.community.append(Card(suit=Suit.CLUB, number=2)) game.community.append(Card(suit=Suit.DIAMOND, number=11)) game.community.append(Card(suit=Suit.SPADE, number=5)) game.community.append(Card(suit=Suit.HEART, number=6)) game.community.append(Card(suit=Suit.DIAMOND, number=7)) #player1 cards player1 = game.players[0] player1.hand.append(Card(suit=Suit.CLUB, number=8)) player1.hand.append(Card(suit=Suit.CLUB, number=9)) #player2 cards player2 = game.players[1] player2.hand.append(Card(suit=Suit.DIAMOND, number=4)) player2.hand.append(Card(suit=Suit.SPADE, number=3)) game.set_player_hands() winner = game.get_winning_player() self.assertEqual(winner[0], player1) self.assertEqual(winner[0].best_hand['score'], Hand.STRAIGHT) self.assertEqual(player2.best_hand['score'], Hand.STRAIGHT) self.assertEqual(player2.best_hand['hand'][0].number, 7) self.assertEqual(player1.best_hand['hand'][0].number, 9)
def test_set_player_best_hands(self): players = [Player(), Player()] game = Game(players) game.deal() game.deal() game.deal() game.deal() game.set_player_hands() player = game.players[0]