Пример #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)

            # Restart game
            if input_coordinates == 'r':
                break

            # Parse input coordinates
            try:
                coordinates = tuple(map(int, input_coordinates.split(',')))
            except ValueError:
                messages.append('Use integers with coma separate: row,column')
                continue

            # Submit users coordinates
            try:
                winner = game.set_move(player, *coordinates)
                last_move = player.nickname, input_coordinates

            except GameAreaUnitException:
                messages.append('This unit is not empty!')
                continue

            except GameAreaIndexException:
                messages.append('You has input a non-existent address.')
                continue

            except TypeError as e:
                error = e.args[0].split(" ")[-1]
                msg = f'You forgot to provide one argument {error}'
                messages.append(msg)
                continue