def _remove_entitlement_from_collectable(collectable, entity_type: str, entity_id: int, ignore_required: bool = False): sourced = compendium.lookup_by_entitlement(entity_type, entity_id) if sourced is None: return error(404, "Entitlement entity not found") return collectable.remove_entitlement(sourced, ignore_required)
def _add_entitlement_to_collectable(collectable, entity_type: str, entity_id: int, required: bool = False): sourced = compendium.lookup_by_entitlement(entity_type, entity_id) if sourced is None: return error(404, "Entitlement entity not found") return collectable.add_entitlement(sourced, required)
async def get_monster(self): """ Gets the Monster associated with the event. Returns None if the event is not associated with a monster. :rtype: gamedata.monster.Monster or None """ if not self.event.entity_id: return None return compendium.lookup_by_entitlement('monster', int(self.event.entity_id))
async def workshop_entitlements_check(ctx, ws_obj): """ :type ws_obj: aliasing.workshop.WorkshopCollectableObject """ entitlements = ws_obj.get_entitlements() # this may take a while, so type await ctx.trigger_typing() # get licensed objects, mapped by entity type available_ids = { k: await ctx.bot.ddb.get_accessible_entities(ctx, ctx.author.id, k) for k in entitlements } # get a list of all missing entities for the license error missing = [] has_connected_ddb = True # run the checks for entity_type, required_ids in entitlements.items(): available_set = available_ids[entity_type] if available_set is None: # user has not connected DDB account has_connected_ddb = False # add all ids of this type to missing for missing_id in required_ids: entity = compendium.lookup_by_entitlement( entity_type, missing_id) if entity is not None: missing.append(entity) elif not available_set.issuperset(required_ids): # add the missing ids to missing for missing_id in set(required_ids).difference(available_set): entity = compendium.lookup_by_entitlement( entity_type, missing_id) if entity is not None: missing.append(entity) if missing: raise CollectableRequiresLicenses(missing, ws_obj, has_connected_ddb)
async def add_orkira(ctx, combat): priest = compendium.lookup_by_entitlement('monster', 16985) orkira = MonsterCombatant.from_monster(monster=priest, ctx=ctx, combat=combat, name="Orkira Illdrex", controller_id=str(ctx.author.id), init=1, private=False, hp=50) combat.add_combatant(orkira) await combat.final() return orkira
async def add_tarrasque(ctx, combat): tarrasque = compendium.lookup_by_entitlement('monster', 17034) terry = MonsterCombatant.from_monster( monster=tarrasque, ctx=ctx, combat=combat, name="TA1", controller_id=str(ctx.bot.user.id), init=12, private=True, ) combat.add_combatant(terry) await combat.final() return terry