Beispiel #1
0
    def test_bent_vertical(self):
        """
        Test that horizontal corridor with bend can be made
        """
        edge_connection = Connection(connection = None,
                                     location = (9, 0),
                                     direction = "down",
                                     section = self.section)

        room_connection = Connection(connection = None,
                                     location = (2, 9),
                                     direction = "up",
                                     section = self.section)

        self.section.connections.append(edge_connection)
        self.section.room_connections.append(room_connection)

        generator = CorridorGenerator(start_point = edge_connection,
                                      end_point = room_connection,
                                      tile = self.wall_empty)

        generator.generate()

        assert_that(self.level.get_wall_tile(9, 0), is_(equal_to(self.wall_empty)))
        assert_that(self.level.get_wall_tile(2, 9), is_(equal_to(self.wall_empty)))
        assert_that(self.level, is_fully_accessible_via(self.wall_empty))
Beispiel #2
0
    def test_catacombs_generation(self):
        """
        Test that catacombs generator creates a fully connected level
        """
        factory = mock(ActionFactory)
        partitioner = GridPartitioner(['crypt'],
                                      1,
                                      1,
                                      self.rng)
        room_generator = CatacombsGenerator(self.floor_rock,
                                             self.wall_empty,
                                             ['crypt'],
                                             self.rng)
        level_decorator = mock()
        portal_adder = PortalAdder((1, 2),
                                  'crypt',
                                  mock(),
                                  self.rng)
        creature_adder = mock()
        item_adder = mock()

        portal = mock(Portal)

        generator = LevelGenerator(factory, partitioner, [room_generator],
                                   level_decorator, [portal_adder],
                                   item_adder,
                                   creature_adder,
                                   self.rng,
                                   LevelContext(size = (60, 40),
                                        floor_type = -2,
                                        wall_type = -101,
                                        empty_floor = 0,
                                        empty_wall = self.wall_empty))

        new_level = generator.generate_level(portal)

        assert_that(new_level, is_fully_accessible_via(self.wall_empty))