Exemple #1
0
def test_move_raises_error_on_unreachable_location():
    """ Tests move validation """
    maze_card_factory = MazeCardFactory()
    board = Board(maze=create_maze(MAZE_STRING, maze_card_factory),
                  leftover_card=maze_card_factory.create_random_maze_card())
    piece = board.create_piece()
    piece.maze_card = board.maze[BoardLocation(0, 1)]
    with pytest.raises(MoveUnreachableException):
        board.move(piece, BoardLocation(0, 0))
Exemple #2
0
def test_move_new_objective_locations_after_reaching_location():
    """ Tests new objective generation after reaching one """
    maze_card_factory = MazeCardFactory()
    maze = create_maze(MAZE_STRING, maze_card_factory)
    objective_maze_card = maze[BoardLocation(1, 6)]
    board = Board(maze=maze,
                  leftover_card=maze_card_factory.create_random_maze_card(),
                  objective_maze_card=objective_maze_card)
    piece = board.create_piece()
    piece.maze_card = maze[BoardLocation(0, 6)]
    board.move(piece, BoardLocation(1, 6))
    _assert_all_piece_and_objective_location_different(board)
Exemple #3
0
def test_move_updates_players_maze_card_correctly():
    """ Tests move
    Instead of calling init_board(), the board is built manually, and
    the player's position is set manually as well, so that
    randomness is eliminated for testing """
    maze_card_factory = MazeCardFactory()
    board = Board(maze=create_maze(MAZE_STRING, maze_card_factory),
                  leftover_card=maze_card_factory.create_random_maze_card())
    piece = board.create_piece()
    piece.maze_card = board.maze[BoardLocation(0, 1)]
    board.move(piece, BoardLocation(0, 2))
    assert board.maze[BoardLocation(0, 2)] == piece.maze_card
Exemple #4
0
def test_move_raises_error_on_invalid_location():
    """ Tests move validation """
    board = Board()
    piece = board.create_piece()
    with pytest.raises(InvalidLocationException):
        board.move(piece, BoardLocation(-1, -1))