def __init__(self, console, level=1): self.tiles = [[Tile(False) for y in range(console.height)] for x in range(console.width)] self.rooms = [] self.entities = [] self.console = console self.fov_map = tcod.Map(console.width, console.height) self.width = console.width self.height = console.height self.fullbright = False self.player = None self.level = level self.stairs = None monster_chances[entities.make_troll] = utils.from_level({3: 15, 5: 30, 7: 60}, level) item_chances[entities.make_lightning_scroll] = utils.from_level({4: 25}, level) item_chances[entities.make_confuse_scroll] = utils.from_level({2: 10}, level) item_chances[entities.make_fireball_scroll] = utils.from_level({6: 25}, level)
def populate(self): max_monsters = utils.from_level({1: 2, 4: 3, 6: 5}, self.map.level) monster_count = tcod.random.get_int(max_monsters) for i in range(monster_count): x = tcod.random.get_int(self.x1+1, self.x2-1) y = tcod.random.get_int(self.y1+1, self.y2-1) monster = make_random_monster(x, y) if monster.can_pass(0, 0, self.map): self.map.add_entity(monster) max_items = utils.from_level({1: 1, 4: 2}) item_count = tcod.random.get_int(max_items) for i in range(item_count): x = tcod.random.get_int(self.x1+1, self.x2-1) y = tcod.random.get_int(self.y1+1, self.y2-1) item = make_random_item(x, y) if item.can_pass(0, 0, self.map): self.map.add_entity(item) self.map.entity_to_bottom(item)