示例#1
0
 def from_dict(cls, d):
     if 'monsters' in d:
         d['monsters'] = [
             Monster.from_bestiary(m, d['name']) for m in d['monsters']
         ]
     if 'published' not in d:  # versions prior to v1.5.11 don't have this tag, default to True
         d['published'] = True
     return cls(**d)
示例#2
0
 async def load_monsters(self, ctx):
     if not self._monsters:
         bestiary = await ctx.bot.mdb.bestiaries.find_one(
             {"_id": self.id}, projection=['monsters'])
         self._monsters = [
             Monster.from_bestiary(m, self.name)
             for m in bestiary['monsters']
         ]
     return self._monsters