Exemplo n.º 1
0
    def _get_custom_counters(self):
        out = []

        for cons in self.character_data['consumables']:
            live_id = f"{cons['id']}-{cons['typeId']}"
            display_type = 'bubble' if cons['max'] < 7 else None
            reset = RESET_MAP.get(cons['reset'], 'long')
            name = cons['name'].replace('\u2019', "'").strip()
            desc = cons['desc'].replace('\u2019', "'") if cons['desc'] is not None else None
            source_feature_type = cons['sourceFeatureType']
            source_feature_id = cons['sourceFeatureId']

            source_feature = compendium.lookup_entity(source_feature_type, source_feature_id)
            log.debug(f"Processed counter named {name!r} for feature {source_feature}")

            if source_feature is None:
                log.warning(f"Could not find source feature ({source_feature_type}, {source_feature_id}) for counter "
                            f"named {name!r}")

            if cons['max'] and name:  # don't make counters with a range of 0 - 0, or blank named counters
                out.append(
                    CustomCounter(None, name, cons['value'], minv='0', maxv=str(cons['max']), reset=reset,
                                  display_type=display_type, live_id=live_id, desc=desc,
                                  ddb_source_feature_type=source_feature_type, ddb_source_feature_id=source_feature_id)
                )

        return [cc.to_dict() for cc in out]
Exemplo n.º 2
0
 def create_cc_nx(name: str, minVal: str = None, maxVal: str = None, reset: str = None,
                  dispType: str = None):
     if not cc_exists(name):
         from cogs5e.models.sheet.player import CustomCounter
         new_consumable = CustomCounter.new(character, name, minVal, maxVal, reset, dispType)
         character.consumables.append(new_consumable)
         self.character_changed = True
Exemplo n.º 3
0
    def __init__(self, owner: str, upstream: str, active: bool,
                 sheet_type: str, import_version: int, name: str,
                 description: str, image: str, stats: BaseStats,
                 levels: Levels, attacks: AttackList, skills: Skills,
                 resistances: Resistances, saves: Saves, ac: int, max_hp: int,
                 hp: int, temp_hp: int, cvars: dict, options: dict,
                 overrides: dict, consumables: list, death_saves: dict,
                 spellbook: Spellbook, 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

        # StatBlock super call
        super(Character, self).__init__(name=name,
                                        stats=stats,
                                        levels=levels,
                                        attacks=attacks,
                                        skills=skills,
                                        saves=saves,
                                        resistances=resistances,
                                        spellbook=spellbook,
                                        ac=ac,
                                        max_hp=max_hp,
                                        hp=hp,
                                        temp_hp=temp_hp)

        # main character info
        self._description = description
        self._image = image

        # 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)

        # 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
Exemplo n.º 4
0
 async def setup(self, ctx, state_map):
     character = await ctx.get_character()
     new_counter = CustomCounter.new(character,
                                     name="Tutorial Counter",
                                     maxv="3",
                                     minv="0",
                                     reset="long",
                                     display_type="bubble")
     character.consumables.append(new_counter)
     await character.commit(ctx)
Exemplo n.º 5
0
    def _get_custom_counters(self):
        out = []

        for cons in self.character_data['consumables']:
            live_id = f"{cons['id']}-{cons['typeId']}"
            display_type = 'bubble' if cons['max'] < 7 else None
            reset = RESET_MAP.get(cons['reset'], 'long')

            if cons['max']:  # don't make counters with a range of 0 - 0
                out.append(
                    CustomCounter(None, cons['name'], cons['value'], minv='0', maxv=str(cons['max']), reset=reset,
                                  display_type=display_type, live_id=live_id)
                )

        return [cc.to_dict() for cc in out]
Exemplo n.º 6
0
    def _get_custom_counters(self):
        out = []

        for cons in self.character_data['consumables']:
            live_id = f"{cons['id']}-{cons['typeId']}"
            display_type = 'bubble' if cons['max'] < 7 else None
            reset = RESET_MAP.get(cons['reset'], 'long')
            name = cons['name'].replace('\u2019', "'").strip()
            desc = cons['desc'].replace('\u2019', "'") if cons['desc'] is not None else None

            if cons['max'] and name:  # don't make counters with a range of 0 - 0, or blank named counters
                out.append(
                    CustomCounter(None, name, cons['value'], minv='0', maxv=str(cons['max']), reset=reset,
                                  display_type=display_type, live_id=live_id, desc=desc)
                )

        return [cc.to_dict() for cc in out]
Exemplo n.º 7
0
    def __init__(self,
                 owner: str,
                 upstream: str,
                 active: bool,
                 sheet_type: str,
                 import_version: int,
                 name: str,
                 description: str,
                 image: str,
                 stats: BaseStats,
                 levels: Levels,
                 attacks: AttackList,
                 skills: Skills,
                 resistances: Resistances,
                 saves: Saves,
                 ac: int,
                 max_hp: int,
                 hp: int,
                 temp_hp: int,
                 cvars: dict,
                 overrides: dict,
                 consumables: list,
                 death_saves: dict,
                 spellbook: Spellbook,
                 live,
                 race: str,
                 background: str,
                 creature_type: str = None,
                 ddb_campaign_id: str = None,
                 actions: Actions = None,
                 active_guilds: list = None,
                 options_v2: CharacterSettings = None,
                 **kwargs):
        if actions is None:
            actions = Actions()
        if active_guilds is None:
            active_guilds = []
        if options_v2 is None:
            if 'options' in kwargs:  # options v1 -> v2 migration (options rewrite)
                options_v2 = CharacterSettings.from_old_csettings(
                    kwargs.pop('options'))
            else:
                options_v2 = CharacterSettings()
        if kwargs:
            log.warning(f"Unused kwargs: {kwargs}")
        # sheet metadata
        self._owner = owner
        self._upstream = upstream
        self._active = active
        self._active_guilds = active_guilds
        self._sheet_type = sheet_type
        self._import_version = import_version

        # StatBlock super call
        super().__init__(name=name,
                         stats=stats,
                         levels=levels,
                         attacks=attacks,
                         skills=skills,
                         saves=saves,
                         resistances=resistances,
                         spellbook=spellbook,
                         ac=ac,
                         max_hp=max_hp,
                         hp=hp,
                         temp_hp=temp_hp,
                         creature_type=creature_type)

        # main character info
        self._description = description
        self._image = image

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

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

        # live sheet resource 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

        # ddb live sync
        self.ddb_campaign_id = ddb_campaign_id
        # action automation
        self.actions = actions