コード例 #1
0
ファイル: initiative.py プロジェクト: Khitiara/avrae
 def from_dict(cls, raw, ctx, combat):
     if raw['saves']:
         saves = Saves.from_dict(raw['saves'])
     else:
         saves = None
     inst = cls(raw['name'], raw['controller'], raw['init'], raw['mod'], raw['hpMax'], raw['hp'], raw['ac'],
                raw['private'], raw['resists'], raw['attacks'], saves, ctx, combat,
                index=raw['index'], notes=raw['notes'], effects=[], group=raw['group'],  # begin backwards compatibility
                temphp=raw.get('temphp'), spellbook=Spellbook.from_dict(raw.get('spellbook', {})))
     inst._effects = [Effect.from_dict(e, combat, inst) for e in raw['effects']]
     return inst
コード例 #2
0
 def from_bestiary(cls, data):
     for key in ('traits', 'actions', 'reactions', 'legactions'):
         data[key] = [Trait(**t) for t in data.pop(key)]
     data['spellcasting'] = Spellbook.from_dict(data.pop('spellbook'))
     data['saves'] = Saves.from_dict(data['saves'])
     data['skills'] = Skills.from_dict(data['skills'])
     data['ability_scores'] = BaseStats.from_dict(data['ability_scores'])
     data['attacks'] = AttackList.from_dict(data['attacks'])
     if 'display_resists' in data:
         data['display_resists'] = Resistances.from_dict(
             data['display_resists'])
     return cls(**data)