Пример #1
0
    def test(path):

        flo = Flo(path)

        game = Game(flo._mock_roller)

        game.play()

        flo._exit()
Пример #2
0
    def test(path):

        flo = Flo(path)

        game = Game(flo._mock_roller)
        try:
            game.play()
        except SystemExit:
            flo.old_print("no problemo")
        finally:
            flo._exit()
Пример #3
0
    def play(cls, num_games=1):

        mega_total = 0

        for i in range(num_games):
            player = cls()
            game = Game()  # doesn't pass a mock roller
            try:
                game.play()
            except SystemExit:
                # in game system exit is fine
                # because that's how they quit.
                pass

            mega_total += player.total_score
            player.reset()

        print(
            f"{num_games} games (maybe) played with average score of {mega_total // num_games}"
        )
Пример #4
0
    def play(cls, num_games=1):
        """Tell Bot play game a given number of times.
        Will report average score"""

        mega_total = 0

        for _ in range(num_games):
            player = cls()
            game = Game()
            try:
                game.play()
            except SystemExit:
                # in game system exit is fine
                # because that's how they quit.
                pass

            mega_total += player.total_score
            player.reset()

        print(
            f"{cls.__name__}: {num_games} games played with average score of {mega_total // num_games}"
        )
def change(str):
    builtins.print = mock_print # overwrite the normal print to be mock_print
    print(str)
    game = Game()
    game.play()
    builtins.print = old_print