def place_creatures(self, creatures, creature_list, level): """ Place creatures into a level :param creatures: creatures to place :type creatures: [Character] :param creature_list: specification where to place creatures :type creature_list: dict :param level: level to place creatures :type level: Level """ for creature in creatures: location_types = [x['location'] for x in creature_list if x['name'] == creature.name] if not location_types: location_types = ['any'] locations = [] for location_type in location_types: locations.extend([location for location in (get_locations_by_tag(level, location_type)) if safe_passage(level, location)]) if locations: location = self.rng.choice(locations) add_character(level, location, creature)
def place_creatures(self, creatures, creature_list, level): """ Place creatures into a level :param creatures: creatures to place :type creatures: [Character] :param creature_list: specification where to place creatures :type creature_list: dict :param level: level to place creatures :type level: Level """ for creature in creatures: location_types = [ x['location'] for x in creature_list if x['name'] == creature.name ] if not location_types: location_types = ['any'] locations = [] for location_type in location_types: locations.extend([ location for location in ( get_locations_by_tag(level, location_type)) if safe_passage(level, location) ]) if locations: location = self.rng.choice(locations) add_character(level, location, creature)
def add_portal(self, level): """ Add given stairs to the level :param level: level to modify :type level: Level """ locations = [x for x in get_locations_by_tag(level, self.location_type) if safe_passage(level, x)] if locations: location = self.rng.choice(locations) portal = Portal(icons=self.icons, level_generator_name=self.level_generator_name) portal.exits_dungeon = self.escape_stairs add_portal(level, location, portal)
def add_portal(self, level): """ Add given stairs to the level :param level: level to modify :type level: Level """ locations = [ x for x in get_locations_by_tag(level, self.location_type) if safe_passage(level, x) ] if locations: location = self.rng.choice(locations) portal = Portal(icons=self.icons, level_generator_name=self.level_generator_name) portal.exits_dungeon = self.escape_stairs add_portal(level, location, portal)
def place_items(self, items, level): """ Place items to level :param items: list of tupples (item_spec, item) :param level: level to place items :type level: Level """ for item in items: location_type = item[0]['location'] if location_type is None: location_type = 'any' locations = [location for location in (get_locations_by_tag(level, location_type)) if safe_passage(level, location)] if locations: location = self.rng.choice(locations) add_item(level, location, item[1])
def place_items(self, items, level): """ Place items to level :param items: list of tupples (item_spec, item) :param level: level to place items :type level: Level """ for item in items: location_type = item[0]['location'] if location_type is None: location_type = 'any' locations = [ location for location in (get_locations_by_tag(level, location_type)) if safe_passage(level, location) ] if locations: location = self.rng.choice(locations) add_item(level, location, item[1])