Exemple #1
0
def test_do_rooms_overlap_with_overlapping_tiles_returns_true():
    room_one = Burrow()
    room_two = Burrow()
    room_one.set_tiles([Tile(0, 0, None), Tile(1, 1, None)])
    room_two.set_tiles([Tile(1, 1, None), Tile(3, 3, None)])

    assert TileGeometry.do_rooms_overlap(room_one, room_two)
Exemple #2
0
def test_can_have_multiple_empty_tiles(test_room):
    tile_one = Tile(5, 11, DungeonCardValues.EMPTY)
    tile_two = Tile(5, 12, DungeonCardValues.EMPTY)
    test_room.add_tile(DungeonCardValues.EMPTY, 5, 11)
    test_room.add_tile(DungeonCardValues.EMPTY, 5, 12)
    assert tile_one in test_room.get_tiles()
    assert tile_two in test_room.get_tiles()
Exemple #3
0
def test_shift_tile_list_0_0_and_0_1_to_1_0_returns_1_0_and_1_1():
    tiles_to_move = [Tile(0, 0, None), Tile(0, 1, None)]
    tile_to_shift_to = Tile(1, 0, None)

    actual = ShiftTile.shift_tile_list(tiles_to_move, tile_to_shift_to)

    expected = [Tile(1, 0, None), Tile(1, 1, None)]
    assert actual == expected
Exemple #4
0
def test_tile_character_attribute_does_not_change_after_being_recentered():
    attribute = DungeonCardValues.TREASURE
    tile_to_be_recentered = Tile(0, 0, attribute)
    tile_to_recenter_around = Tile(0, 1, None)

    actual = CenterTile.recenter_tile(tile_to_be_recentered,
                                      tile_to_recenter_around)

    assert actual.get_character_number() == DungeonCardValues.TREASURE
Exemple #5
0
 def serialize(self, serializable_object: Tile):
     return {
         'x':
         serializable_object.get_x(),
         'y':
         serializable_object.get_y(),
         'z':
         serializable_object.get_z(),
         'value':
         self.enum_serializer.serialize(
             serializable_object.get_character_number()),
     }
Exemple #6
0
def test_rotation_algorithm_fails_on_arbitrary_edge_case(waypoint_b):
    room_one = Burrow()
    room_two = Tunnel()

    tile_coordinate_list = list(itertools.permutations([-1, 0, 1], 2))
    tiles_surrounding_origin = [
        Tile(coord[0], coord[1], None) for coord in tile_coordinate_list
    ]
    origin_tile = Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_B)
    tiles_surrounding_origin.append(origin_tile)

    room_two.set_tiles(tiles_surrounding_origin)

    with pytest.raises(AssertionError, match="TileGeometry algorithm failed"):
        TileGeometry.overlay_room_a_on_room_b(room_one, room_two, waypoint_b)
Exemple #7
0
def test_center_burrow_on_entrance_b(waypoint_b):
    room = Burrow()
    assert waypoint_b.has_entrance(room)
    actual = CenterTile.center_on_entrance(room, waypoint_b)
    tile = waypoint_b.get_entrance(actual)
    assert tile == Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_B)
    assert isinstance(actual, Burrow)
Exemple #8
0
def test_tile_and_dog_object_are_not_equal():
    tile = Tile(0, 0, None)

    class Dog:  # pylint: disable=too-few-public-methods
        pass

    assert Dog() != tile
Exemple #9
0
def test_recentering_tile0_0_around_0_1_has_coordinates_0_minus_1():
    tile_to_be_recentered = Tile(0, 0, None)

    tile_to_recenter_around = Tile(0, 1, None)

    actual = CenterTile.recenter_tile(tile_to_be_recentered,
                                      tile_to_recenter_around)

    actual_x = actual.get_x()
    actual_y = actual.get_y()

    expected_x = 0
    expected_y = -1

    assert expected_x == actual_x
    assert expected_y == actual_y
Exemple #10
0
def test_center_hovel_on_entrance_a(waypoint_a):
    room = Hovel()
    assert waypoint_a.has_entrance(room)
    actual = CenterTile.center_on_entrance(room, waypoint_a)
    tile = waypoint_a.get_entrance(actual)
    assert tile == Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_A)
    assert isinstance(actual, Hovel)
Exemple #11
0
def test_center_on_entrance_b_causes_entrance_to_have_coordinate_0_0(
        waypoint_b):
    room = Tunnel()
    new_room = CenterTile.center_on_entrance(room, waypoint_b)
    actual = waypoint_b.get_entrance(new_room)

    assert actual == Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_B)
    assert actual.get_x() == 0
    assert actual.get_y() == 0
Exemple #12
0
def test_recentering_tile_0_0_returns_tile_with_coordinates_0_0():
    x_coordinate = 0
    y_coordinate = 0
    tile_to_be_recentered = Tile(x_coordinate, y_coordinate, None)

    tile_to_recenter_around = Tile(x_coordinate, y_coordinate, None)

    actual = CenterTile.recenter_tile(tile_to_be_recentered,
                                      tile_to_recenter_around)

    actual_x = actual.get_x()
    actual_y = actual.get_y()

    expected_x = 0
    expected_y = 0

    assert isinstance(actual, Tile)
    assert expected_x == actual_x
    assert expected_y == actual_y
Exemple #13
0
def test_recenters_list_of_tiles_around_a_tile():
    tile_one = Tile(0, 1, None)
    tile_two = Tile(1, 0, None)
    tile_list = [tile_one, tile_two]
    tile_to_be_recentered_around = Tile(-1, 1, None)

    actual = CenterTile.recenter_tile_list(tile_list,
                                           tile_to_be_recentered_around)
    new_tile_one = actual[0]
    new_tile_two = actual[1]
    expected_tile_one_x = 1
    expected_tile_one_y = 0
    expected_tile_two_x = 2
    expected_tile_two_y = -1

    assert new_tile_one.get_x() == expected_tile_one_x
    assert new_tile_one.get_y() == expected_tile_one_y
    assert new_tile_two.get_x() == expected_tile_two_x
    assert new_tile_two.get_y() == expected_tile_two_y
Exemple #14
0
    def add_tile(self, character_number, x_value, y_value):
        new_tile = Tile(x_value, y_value, character_number)
        coordinates = (x_value, y_value)
        coordinates_in_tile_list = ((tile.get_x(), tile.get_y())
                                    for tile in self.tiles)
        attributes = (tile.get_character_number() for tile in self.tiles)

        if isinstance(character_number, UniqueTileValues) \
                and character_number in attributes:
            raise DuplicateTileError
        if coordinates in coordinates_in_tile_list:
            raise DuplicateTileError
        self.tiles.append(new_tile)
Exemple #15
0
def test_is_entrance_a_on_tile_returns_true(waypoint_a):
    tile = Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_A)
    actual = waypoint_a.is_entrance(tile)
    expected = True
    assert actual == expected
Exemple #16
0
def test_rotate_tile_minus_2_1_returns_tile_minus_1_2():
    tile = Tile(-2, 1, None)
    actual = tile.rotate()

    assert actual == Tile(-1, 2, None)
Exemple #17
0
def test_rotate_tile_returns_tile_with_same_character_number():
    attribute = NumberedRoomTileValues.ONE
    tile = Tile(0, 0, attribute)
    actual = tile.rotate()

    assert actual.get_character_number() == attribute
Exemple #18
0
def test_shift_tile_0_0_to_1_2_returns_1_2():
    tile_to_move = Tile(0, 0, None)
    tile_to_shift_to = Tile(1, 2, None)
    actual = ShiftTile.shift_tile(tile_to_move, tile_to_shift_to)
    assert actual == tile_to_shift_to
Exemple #19
0
def test_get_exit_b_on_burrow(waypoint_b):
    room = Burrow()
    actual = waypoint_b.get_exit(room)
    assert actual == Tile(-1, -4, UniqueDungeonCardValues.EXIT_B)
Exemple #20
0
def create_tile_b():
    return Tile(0, 0, DungeonCardValues.COIN)
Exemple #21
0
def test_rotate_tile_1_0_returns_tile_0_minus_1():
    tile = Tile(1, 0, None)
    actual = tile.rotate()

    assert actual == Tile(1, -1, None)
Exemple #22
0
def test_get_entrance_a_on_trail_returns_entrance_tile(waypoint_a):
    room = Trail()
    actual = waypoint_a.get_entrance(room)
    expected = Tile(-2, 5, UniqueDungeonCardValues.ENTRANCE_A)
    assert actual == expected
Exemple #23
0
 def shift_tile(tile_to_move, tile_to_shift_to):
     new_x = tile_to_shift_to.get_x() + tile_to_move.get_x()
     new_y = tile_to_shift_to.get_y() + tile_to_move.get_y()
     character_number = tile_to_move.get_character_number()
     return Tile(new_x, new_y, character_number)
Exemple #24
0
def test_recenter_room_on_tile(waypoint_b):
    room = Burrow()
    actual = CenterTile.center_on_entrance(room, waypoint_b)
    assert waypoint_b.get_entrance(actual) == Tile(
        0, 0, UniqueDungeonCardValues.ENTRANCE_B)
Exemple #25
0
def test_get_entrance_b_on_hovel_returns_entrance_tile(waypoint_b):
    room = Hovel()
    actual = waypoint_b.get_entrance(room)
    expected = Tile(0, 3, UniqueDungeonCardValues.ENTRANCE_B)
    assert actual == expected
Exemple #26
0
def test_is_entrance_b_on_non_entrance_return_false(waypoint_b):
    tile = Tile(0, 0, UniqueDungeonCardValues.ENTRANCE_A)
    actual = waypoint_b.is_entrance(tile)
    expected = False
    assert actual == expected
Exemple #27
0
def test_hash():
    actual = hash(Tile(0, 0, NumberedRoomTileValues.ONE))
    expected = hash((0, 0, NumberedRoomTileValues.ONE))
    assert actual == expected
Exemple #28
0
def test_add_tile(test_room):
    current_tile = Tile(5, 10, DungeonCardValues.EMPTY)
    test_room.add_tile(DungeonCardValues.EMPTY, 5, 10)
    assert current_tile in test_room.get_tiles()
Exemple #29
0
def test_repr():
    tile = Tile(0, 0, NumberedRoomTileValues.ONE)
    expected = '{} {} {}'.format(0, 0, NumberedRoomTileValues.ONE)
    assert tile.__repr__() == expected
Exemple #30
0
 def recenter_tile(tile_to_move, tile_to_center_around):
     new_x = tile_to_move.get_x() - tile_to_center_around.get_x()
     new_y = tile_to_move.get_y() - tile_to_center_around.get_y()
     character_number = tile_to_move.get_character_number()
     return Tile(new_x, new_y, character_number)