示例#1
0
    def test_portal_has_icons(self):
        """
        Test that portal created by adder has two icons set
        One to display and another to be used by opposite end
        """
        level = (LevelBuilder()
                 .with_size((20, 20))
                 .with_floor_tile(self.floor_rock)
                 .with_wall_tile(self.wall_empty)
                 .build())

        level_generator = mock()

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2),
                                   'room',
                                   level_generator,
                                   False,
                                   self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)
        portal = portals[0]

        assert_that(portal.icon, is_(equal_to(1)))
        assert_that(portal.other_end_icon, is_(equal_to(2)))
    def test_portal_has_icons(self):
        """
        Test that portal created by adder has two icons set
        One to display and another to be used by opposite end
        """
        level = (LevelBuilder().with_size((20, 20)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_empty).build())

        level_generator = mock()

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2), 'room', level_generator, False,
                                   self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)
        portal = portals[0]

        assert_that(portal.icon, is_(equal_to(1)))
        assert_that(portal.other_end_icon, is_(equal_to(2)))
示例#3
0
    def test_add_stairs_to_room(self):
        """
        Test that stairs can be added to a room
        """
        level = (LevelBuilder()
                 .with_size((20, 20))
                 .with_floor_tile(self.floor_rock)
                 .with_wall_tile(self.wall_empty)
                 .build())

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2),
                                   'room',
                                   mock(),
                                   False,
                                   self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)

        assert_that(portals, has_length(1))
        portal = portals[0]
        assert_that(located_in_room(portal), is_(True))
    def test_add_stairs_to_room(self):
        """
        Test that stairs can be added to a room
        """
        level = (LevelBuilder().with_size((20, 20)).with_floor_tile(
            self.floor_rock).with_wall_tile(self.wall_empty).build())

        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                add_location_tag(level, (loc_x, loc_y), 'room')

        portal_adder = PortalAdder((1, 2), 'room', mock(), False, self.rng)

        portal_adder.add_portal(level)

        portals = []
        for loc_y in range(8, 12):
            for loc_x in range(8, 12):
                temp = get_portal(level, (loc_x, loc_y))
                if temp:
                    portals.append(temp)

        assert_that(portals, has_length(1))
        portal = portals[0]
        assert_that(located_in_room(portal), is_(True))