Пример #1
0
    def __init__(self, owner: str, upstream: str, active: bool,
                 sheet_type: str, import_version: int, name: str,
                 description: str, image: str, stats: dict, levels: dict,
                 attacks: list, skills: dict, resistances: dict, saves: dict,
                 ac: int, max_hp: int, hp: int, temp_hp: int, cvars: dict,
                 options: dict, overrides: dict, consumables: list,
                 death_saves: dict, spellbook: dict, live, race: str,
                 background: str, **kwargs):
        if kwargs:
            log.warning(f"Unused kwargs: {kwargs}")
        # sheet metadata
        self._owner = owner
        self._upstream = upstream
        self._active = active
        self._sheet_type = sheet_type
        self._import_version = import_version

        # main character info
        self.name = name
        self._description = description
        self._image = image
        self.stats = BaseStats.from_dict(stats)
        self.levels = Levels.from_dict(levels)
        self._attacks = [Attack.from_dict(atk) for atk in attacks]
        self.skills = Skills.from_dict(skills)
        self.resistances = Resistances.from_dict(resistances)
        self.saves = Saves.from_dict(saves)

        # hp/ac
        self.ac = ac
        self.max_hp = max_hp
        self._hp = hp
        self._temp_hp = temp_hp

        # customization
        self.cvars = cvars
        self.options = CharOptions.from_dict(options)
        self.overrides = ManualOverrides.from_dict(overrides)

        # ccs
        self.consumables = [
            CustomCounter.from_dict(self, cons) for cons in consumables
        ]
        self.death_saves = DeathSaves.from_dict(death_saves)

        # spellbook
        spellbook = Spellbook.from_dict(spellbook)
        super(Character, self).__init__(spellbook)

        # live sheet integrations
        self._live = live
        integration = INTEGRATION_MAP.get(live)
        if integration:
            self._live_integration = integration(self)
        else:
            self._live_integration = None

        # misc research things
        self.race = race
        self.background = background
Пример #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'])
     return cls(**data)
Пример #3
0
 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