Пример #1
0
def test_win(player_obj):
    game = Game(*player_obj)
    game.start_game()

    assert game.set_move(game.get_current_player(), 0, 0) is False
    assert game.set_move(game.get_current_player(), 1, 0) is False
    assert game.set_move(game.get_current_player(), 1, 1) is False
    assert game.set_move(game.get_current_player(), 2, 0) is False
    assert game.set_move(game.get_current_player(), 2, 2) is not False
Пример #2
0
    sys.exit(0)

if action == 's':
    player1 = input('Enter player1 name: ')
    player2 = input('Enter player2 name: ')

    p1 = Player(str(player1))
    p2 = Player(str(player2))

    # Game session loop
    game_session_flag = True

    while game_session_flag:
        # Init game
        game = Game(p1, p2)
        game.start_game()

        # Current game data
        last_move = ['', '']
        winner = False
        messages = []
        current_game_flag = True

        # Current game loop
        while current_game_flag:
            # Show current game
            flag = show_game(game, last_move, winner, messages)
            if flag:
                break
            elif not flag and flag is not None:
                print('Bye!')