Exemple #1
0
 def test_game(self):
     game = Game()
     player = Player("tyna")
     player2 = Player("pawel")
     game.players = [player, player2]
     game.current_player = player
     game.player_action({'Action name': 'Bet', 'Amount': 200})
Exemple #2
0
    def test_check_available_true(self):
        players = []
        players.append(Player("Pawel"))
        players.append(Player("Karolina"))

        result = check_available(players, players[0])

        self.assertEqual(result, True)
Exemple #3
0
    def test_place_bet_correct(self):
        player = Player('Tyna')
        player.balance = 5000

        res = player.place_bet(200)
        com = (res == {'result': 'OK'})

        self.assertEqual(com, True)
Exemple #4
0
    def test_place_bet_incorect(self):
        player = Player('Tyna')
        player.balance = 100

        res = player.place_bet(200)
        res = res['result']

        self.assertEqual(res, 'ERROR')
Exemple #5
0
    def test_bet_available_false(self):
        players = []
        players.append(Player("Pawel"))
        players.append(Player("Karolina"))

        players[1].bet = 1000

        result = bet_available(players, players[0])

        self.assertEqual(result, False)
    def test_check_one_player_left_one_inactive(self):

        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))

        game.players[1].active = False

        result = game.check_number_of_players_left()
        self.assertEqual(result, 1)
    def test_check_two_players_left_one_folded(self):

        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))
        game.add_player(Player("Tyna"))

        game.players[1].folded = True

        result = game.check_number_of_players_left()
        self.assertEqual(result, 2)
Exemple #8
0
    def test_check_betting_fished_true_player_all_in(self):
        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))
        game.players[0].bet = 0
        game.players[1].bet = 0
        game.players[0].all_in_state = True

        result = game.check_betting_fished()

        self.assertEqual(result, True)
Exemple #9
0
    def test_all_in_available_true(self):
        players = []
        players.append(Player("Pawel"))
        players.append(Player("Karolina"))

        players[1].bet = 3000
        players[0].bet = 1000
        players[0].balance = 200

        result = all_in_available(players, players[0])

        self.assertEqual(result, True)
Exemple #10
0
    def test_call_available_higher_bet_false(self):
        players = []
        players.append(Player("Pawel"))
        players.append(Player("Karolina"))

        players[0].bet = 3000
        players[1].bet = 2000
        players[0].balance = 200

        result = call_available(players, players[0])

        self.assertEqual(result, False)
Exemple #11
0
    def test_check_betting_fished_false_betting_not_ended(self):
        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))
        game.players[0].bet = 0
        game.players[1].bet = 0
        game.players[0].bet_placed = True
        game.players[1].bet_placed = False

        result = game.check_betting_fished()

        self.assertEqual(result, False)
Exemple #12
0
    def test_check_betting_fished_all_200_true(self):
        # Arrange
        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))
        game.players[0].bet = 200
        game.players[1].bet = 200
        game.players[0].bet_placed = True
        game.players[1].bet_placed = True

        # Act(?)
        result = game.check_betting_fished()

        # Assert
        self.assertEqual(result, True)
Exemple #13
0
    def test_check_betting_fished_true_players_inactive(self):
        game = Game()
        game.add_player(Player("Pawel"))
        game.add_player(Player("Karolina"))
        game.add_player(Player("Tyna"))
        game.players[0].bet = 220
        game.players[1].bet = 220
        game.players[2].bet = 0
        game.players[0].bet_placed = True
        game.players[1].bet_placed = True
        game.players[2].active = False

        result = game.check_betting_fished()

        self.assertEqual(result, True)
Exemple #14
0
 def get_players(self, my_player):
     result = []
     for p in self.players:
         new_p = Player(name=p.name,
                        balance=p.balance,
                        bet=p.bet,
                        bet_placed=p.bet_placed,
                        active=p.active,
                        folded=p.folded,
                        all_in_state=p.all_in_state,
                        ready=p.ready)
         if p.name == my_player:
             new_p.cards = p.cards
         else:
             new_p.cards = Hand(
                 cards=[Card(
                     covered=True), Card(covered=True)])
         result.append(new_p)
     return result
Exemple #15
0
 def create_default_players(self, number_of_players):
     players_tab = []
     players_tab = [
         Player("Player " + str(i + 1)) for i in range(number_of_players)
     ]
     return players_tab
Exemple #16
0
 def add_player(self, name):
     player = Player(name)
     self.players.append(player)
     return player