コード例 #1
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_multiple_players(self):
        # add players to players array
        _players = []

        _players.append(self.players.get('pair'))
        _players.append(self.players.get('two_pair'))
        _players.append(self.players.get('trips'))
        _players.append(self.players.get('full_house'))

        # add players to players_diff_order array
        _players_diff_order = []
        _players_diff_order.append(self.players.get('full_house'))
        _players_diff_order.append(self.players.get('trips'))
        _players_diff_order.append(self.players.get('two_pair'))
        _players_diff_order.append(self.players.get('pair'))

        # winning description and results of winninghand
        _winning_desc = 'full house'
        r_player, r_winning_desc = winninghand(_players)
        r_do_player, r_do_winning_desc = winninghand(_players_diff_order)

        # tests
        self.assertEqual(r_player, self.players.get('full_house'))
        self.assertEqual(r_winning_desc, _winning_desc)
        self.assertEqual(r_do_player, self.players.get('full_house'))
        self.assertEqual(r_do_winning_desc, _winning_desc)
コード例 #2
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_tied_straight(self):
        _players = [
            self.players.get('tied_hand_straight'),
            self.players.get('tied_hand_straight')
        ]

        _winning_desc = 'straight'
        r_players, r_winning_desc = winninghand(_players)

        self.assertEqual(_players, r_players)
        self.assertEqual(_winning_desc, r_winning_desc)
コード例 #3
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_tied_two_pair(self):
        _players = [
            self.players.get('tied_hand_two_pair'),
            self.players.get('tied_hand_two_pair_two')
        ]

        _winning_desc = 'two pair'
        r_players, r_winning_desc = winninghand(_players)

        self.assertEqual(_players, r_players)
        self.assertEqual(_winning_desc, r_winning_desc)
コード例 #4
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_tied_high_card(self):
        _players = [
            self.players.get('tied_hand_high_card'),
            self.players.get('tied_hand_high_card_two')
        ]

        _winning_desc = 'high card'
        r_players, r_winning_desc = winninghand(_players)

        self.assertEqual(_players, r_players)
        self.assertEqual(_winning_desc, r_winning_desc)
コード例 #5
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_same_ranking_fullhouse(self):
        _players = [
            self.players.get('full_house'),
            self.players.get('full_house_aces')
        ]
        _players_diff_order = [
            self.players.get('full_house_aces'),
            self.players.get('full_house')
        ]

        # results
        _winning_desc = 'full house'
        r_player, r_winning_desc = winninghand(_players)
        r_do_player, r_do_winning_desc = winninghand(_players_diff_order)

        # tests
        self.assertEqual(r_player, self.players.get('full_house_aces'))
        self.assertEqual(r_winning_desc, _winning_desc)
        self.assertEqual(r_do_player, self.players.get('full_house_aces'))
        self.assertEqual(r_do_winning_desc, _winning_desc)
コード例 #6
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_pair_vs_trips(self):
        # add to players array
        _players = [self.players.get('pair'), self.players.get('trips')]

        # winning description and results of winninghand
        _winning_desc = 'trips'
        r_player, r_winning_desc = winninghand(_players)

        # tests
        self.assertEqual(r_player, self.players.get('trips'))
        self.assertEqual(r_winning_desc, _winning_desc)
コード例 #7
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_same_ranking_flush(self):
        # load two types of ordering of player arrays
        _players = [
            self.players.get('flush_same_rank'),
            self.players.get('flush_same_rank_win')
        ]
        _players_diff_order = [
            self.players.get('flush_same_rank_win'),
            self.players.get('flush_same_rank')
        ]

        # results
        _winning_desc = 'flush'
        r_player, r_winning_desc = winninghand(_players)
        r_do_player, r_do_winning_desc = winninghand(_players_diff_order)

        # tests
        self.assertEqual(r_player, self.players.get('flush_same_rank_win'))
        self.assertEqual(r_winning_desc, _winning_desc)
        self.assertEqual(r_do_player, self.players.get('flush_same_rank_win'))
        self.assertEqual(r_do_winning_desc, _winning_desc)
コード例 #8
0
ファイル: test_pokerengine.py プロジェクト: edluong/fivedraw
    def test_same_ranking_high_card(self):
        # load two types of ordering of player arrays
        _players = [
            self.players.get('high_card'),
            self.players.get('high_card_ace')
        ]
        _players_diff_order = [
            self.players.get('high_card_ace'),
            self.players.get('high_card')
        ]

        # results
        _winning_desc = 'high card'
        r_player, r_winning_desc = winninghand(_players)
        r_do_player, r_do_winning_desc = winninghand(_players_diff_order)

        # tests
        self.assertEqual(r_player, self.players.get('high_card_ace'))
        self.assertEqual(r_winning_desc, _winning_desc)
        self.assertEqual(r_do_player, self.players.get('high_card_ace'))
        self.assertEqual(r_do_winning_desc, _winning_desc)
コード例 #9
0
ファイル: game.py プロジェクト: edluong/fivedraw
    def payout(self):
        '''
            finds the winner
            pay the winner with the pot
            set the pot to 0
        '''
        if self.state > 0:
            _win_player_text = ''
            _winner, _win_desc = winninghand([self.cpu, self.player])

            if isinstance(_winner, list):
                _num_of_winner = len(_winner)
                split_pot = self.pot_size / _num_of_winner
                _win_player_text = 'Player and CPU tied.'

                # TODO - need to make this more generalized for more than two players
                self.player.stack += split_pot
                self.cpu.stack += split_pot
            else:
                if _winner == self.player:
                    _win_player_text = 'Player'  
                    self.player.stack = self.player.stack + self.pot_size
                elif _winner == self.cpu: 
                    _win_player_text = 'CPU'
                    self.cpu.stack = self.cpu.stack + self.pot_size
                else:
                    print('there is something wrong...')

            print(f'{_win_player_text} wins with {_win_desc}!')
            print(f'{_win_player_text} wins {self.pot_size} from the pot\n')
            print(f'Player Stack Size: {self.player.stack}')
            print(f'CPU Stack Size: {self.cpu.stack}\n')

            # reset the pot size
            self.pot_size = 0
            self.state = 4
        else:
            return