Example #1
0
def test_whenNextBoardIsFinishedThenAnyBoardCanBePlayed():
    main_board = MainBoard()
    # Force some sub_board plays to finish a board
    finished_sub_board = main_board._board[2][2] \
        .add_my_move(SubBoardCoords(0, 0)) \
        .add_my_move(SubBoardCoords(1, 1)) \
        .add_my_move(SubBoardCoords(2, 2))

    # Set that sub-board where the sub_board_next_player_must_play will be
    main_board._board[2][2] = finished_sub_board
    # Play a move that will make the finished board the next board (Move 2, 2)
    main_board = main_board.add_my_move(MainBoardCoords(0, 0), SubBoardCoords(2, 2))
    # Playing anywhere is now allowed
    assert main_board.sub_board_next_player_must_play == None
    assert main_board.is_playing_on_sub_board_allowed(MainBoardCoords(1, 1)) == True
    main_board.add_opponent_move(MainBoardCoords(0, 0), SubBoardCoords(1, 1))
Example #2
0
def test_whenNewMoveIsNotOnGameNextBoardThenExceptionRaised():
    board = MainBoard().add_my_move(MainBoardCoords(0, 0), SubBoardCoords(1, 1))

    # Move must now be on board at 1, 1
    with pytest.raises(MoveNotOnNextBoardError):
        board.add_opponent_move(MainBoardCoords(1, 0), SubBoardCoords(1, 1))