def __init__(self, floor_tile, corridor_tile, empty_tile, pillar_tile, level_types): """ Default constructor :param floor_tile: id of the tile to use for floors :type floor_tile: integer :param corridor_tile: id of the tile to use for corridor floors :type corridor_tile: integer :param empty_tile: id of the empty wall tile :type empty_tile: integer :param level_types: types of level this generator can be used :type level_types: [string] """ self.square_generator = SquareRoomGenerator(floor_tile, empty_tile, corridor_tile, level_types) self.floor_tile = floor_tile self.corridor_tile = corridor_tile self.empty_tile = empty_tile self.level_types = level_types self.pillar_tile = pillar_tile self.rng = Random()
class PillarRoomGenerator(): """ Class for generating a pillar room .. versionadded:: 0.8 """ @log_debug def __init__(self, floor_tile, corridor_tile, empty_tile, pillar_tile, level_types): """ Default constructor :param floor_tile: id of the tile to use for floors :type floor_tile: integer :param corridor_tile: id of the tile to use for corridor floors :type corridor_tile: integer :param empty_tile: id of the empty wall tile :type empty_tile: integer :param level_types: types of level this generator can be used :type level_types: [string] """ self.square_generator = SquareRoomGenerator(floor_tile, empty_tile, corridor_tile, level_types) self.floor_tile = floor_tile self.corridor_tile = corridor_tile self.empty_tile = empty_tile self.level_types = level_types self.pillar_tile = pillar_tile self.rng = Random() def __call__(self, section): """ Generate room """ self.generate_room(section) @log_debug def generate_room(self, section): """ Generate room :param section: section for generator to draw to :type section: Section """ self.square_generator.generate_room(section) offset = [(1, 1), (-1, 1), (-1, -1), (1, -1)] for index, corner in enumerate(self.square_generator.room_corners): self.add_pillar(section, corner, offset[index]) @log_debug def add_pillar(self, section, corner, pillar): """ Add pillar if location is free """ location = (corner[0] + pillar[0], corner[1] + pillar[1]) if section_wall(section, location) == self.empty_tile: section_wall(section, location, self.pillar_tile, None) section_floor(section, location, None, None)