def test_whenMainBoardIsFinishedThenGetValidBoardsIsEmpty(): main_board = MainBoard() main_board = force_sub_board_win(main_board, 0, 0, Player.ME) main_board = force_sub_board_win(main_board, 1, 1, Player.ME) main_board = force_sub_board_win(main_board, 2, 2, Player.ME) assert len(main_board.get_playable_coords()) == 0
def test_whenNextBoardIsFinishedThenGetValidBoardsReturnsAllAvailableBoards(): 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 valid_boards = main_board.get_playable_coords() assert len(valid_boards) == 8 assert valid_boards == [MainBoardCoords(0, 0), MainBoardCoords(0, 1), MainBoardCoords(0, 2), MainBoardCoords(1, 0), MainBoardCoords(1, 1), MainBoardCoords(1, 2), MainBoardCoords(2, 0), MainBoardCoords(2, 1)]
def test_whenNextBoardIsAvailableThenGetValidBoardsReturnsOnlyThatBoard(): board = MainBoard().add_my_move(MainBoardCoords(0, 0), SubBoardCoords(2, 2)) # Only valid board now should be 2, 2 assert len(board.get_playable_coords()) == 1 assert board.get_playable_coords()[0] == MainBoardCoords(2, 2)