示例#1
0
def main_game():
    players = [Player('Bob', 500), AiPlayer('Sam', 500)]
    dealer = AiPlayer('Dealer', 5000)
    game = Game(players, dealer)

    print('\nWelcome!\n')
    game.game_loop()
    print('\nThanks for playing!')
示例#2
0
    def test_game_loop_out_of_budget(self, _print_mock,
                                     single_game_mock):
        budget = 500
        player = Player('Bob', budget)
        players = [player]
        dealer = AiPlayer('Dealer', 5000)

        def single_game(self):
            for player in self.players:
                player.budget = 0
        single_game_mock.side_effect = single_game

        game = Game(players, dealer)
        game.game_loop()

        self.assertFalse(game.players)
示例#3
0
    def test_game_loop_no_continue(self, _print_mock,
                                   get_answer_mock,
                                   single_game_mock):
        budget = 500
        player = Player('Bob', budget)
        players = [player]
        dealer = AiPlayer('Dealer', 5000)

        def single_game(self):
            for player in self.players:
                player.budget = 0
        single_game_mock.side_effect = single_game
        get_answer_mock.return_value = 'n'

        game = Game(players, dealer)
        game.game_loop()

        self.assertFalse(game.players)