def __init__(self): self.cfeats = self.load_json('srd-classfeats.json', []) self.classes = self.load_json('srd-classes.json', []) self.conditions = self.load_json('conditions.json', []) self.feats = self.load_json('srd-feats.json', []) self.itemprops = self.load_json('itemprops.json', {}) self.monsters = self.load_json('srd-bestiary.json', []) self.names = self.load_json('names.json', []) self.rules = self.load_json('rules.json', []) self.spells = [Spell.from_data(r) for r in self.load_json('srd-spells.json', [])] self.backgrounds = [Background.from_data(b) for b in self.load_json('srd-backgrounds.json', [])] self.items = [i for i in self.load_json('srd-items.json', []) if i.get('type') is not '$'] self.monster_mash = [Monster.from_data(m) for m in self.monsters] self.subclasses = self.load_subclasses() srd_races = self.load_json('srd-races.json', []) self.fancyraces = [Race.from_data(r) for r in srd_races] self.rfeats = [] for race in srd_races: for entry in race['entries']: if isinstance(entry, dict) and 'name' in entry: temp = {'name': "{}: {}".format(race['name'], entry['name']), 'text': parse_data_entry(entry['entries']), 'srd': race['srd']} self.rfeats.append(temp)
def load_common(self): self.backgrounds = [Background.from_data(b) for b in self.srd_backgrounds] self.fancyraces = [Race.from_data(r) for r in self.srd_races] self.monster_mash = [Monster.from_data(m) for m in self.monsters] self.spells = [Spell.from_data(s) for s in self.srd_spells] self.items = [i for i in self.srd_items if i.get('type') is not '$'] self.rfeats = self.load_rfeats() self.subclasses = self.load_subclasses()
async def get_spell_choices(ctx): try: tome = await Tome.from_ctx(ctx) custom_spells = tome.spells tome_id = tome.id except NoActiveBrew: custom_spells = [] tome_id = None choices = list(itertools.chain(c.spells, custom_spells)) if ctx.guild: async for servtome in ctx.bot.mdb.tomes.find({"server_active": str(ctx.guild.id)}, ['spells']): choices.extend(Spell.from_dict(s) for s in servtome['spells'] if servtome['_id'] != tome_id) return choices
def __init__(self): with open('./res/conditions.json', 'r') as f: self.conditions = json.load(f) with open('./res/rules.json', 'r') as f: self.rules = json.load(f) with open('./res/feats.json', 'r') as f: self.feats = json.load(f) with open('./res/races.json', 'r') as f: _raw = json.load(f) self.rfeats = [] self.fancyraces = [Race.from_data(r) for r in _raw] for race in _raw: for entry in race['entries']: if isinstance(entry, dict) and 'name' in entry: temp = { 'name': "{}: {}".format(race['name'], entry['name']), 'text': parse_data_entry(entry['entries']), 'srd': race['srd'] } self.rfeats.append(temp) with open('./res/classes.json', 'r') as f: self.classes = json.load(f) with open('./res/classfeats.json') as f: self.cfeats = json.load(f) with open('./res/bestiary.json', 'r') as f: self.monsters = json.load(f) self.monster_mash = [Monster.from_data(m) for m in self.monsters] with open('./res/spells.json', 'r') as f: self.spells = [Spell.from_data(r) for r in json.load(f)] with open('./res/items.json', 'r') as f: _items = json.load(f) self.items = [i for i in _items if i.get('type') is not '$'] with open('./res/backgrounds.json', 'r') as f: self.backgrounds = [Background.from_data(b) for b in json.load(f)] self.subclasses = self.load_subclasses() with open('./res/itemprops.json', 'r') as f: self.itemprops = json.load(f) with open('./res/names.json', 'r') as f: self.names = json.load(f)