Ejemplo n.º 1
0
    def getRandomMonster(self, difficulty):
        #TODO: read these chances at creation time of the library, no
        #sense in doing it again for every monster

        #chance of each monster
        monster_chances = {}
        for monster_name in self.configParser.get('lists', 'monster list').split(', '):
            chance_table = json.loads(self.configParser.get(monster_name, 'chance'))
            monster_chances[monster_name] = Utilities.from_dungeon_level(chance_table, difficulty)

        #Avoid recreating unique monsters
        for unique_monster in self.uniqueMonsters:
            del monster_chances[unique_monster.id]

        #create a random monster
        choice = Utilities.random_choice(monster_chances)
        monster = self.createMonster(choice)
        return monster
Ejemplo n.º 2
0
 def getMaxMonstersPerRoomForDifficulty(self, difficulty):
     #maximum number of monsters per room
     max_monsters = Utilities.from_dungeon_level(
             json.loads(self.configParser.get('lists', 'max monsters')),
             difficulty)
     return max_monsters