async def __get_dropship_msg_from_info_as_text( daily_info: EntityInfo, chars_data: EntitiesData, collections_data: EntitiesData) -> List[str]: result = [f'{emojis.pss_dropship} **Dropship crew**'] if daily_info: common_crew_id = daily_info['CommonCrewId'] common_crew_details = crew.get_char_details_by_id( common_crew_id, chars_data, collections_data) common_crew_info = await common_crew_details.get_details_as_text( entity.EntityDetailsType.SHORT) hero_crew_id = daily_info['HeroCrewId'] hero_crew_details = crew.get_char_details_by_id( hero_crew_id, chars_data, collections_data) hero_crew_info = await hero_crew_details.get_details_as_text( entity.EntityDetailsType.SHORT) common_crew_rarity = common_crew_details.entity_info['Rarity'] if common_crew_rarity in [ 'Unique', 'Epic', 'Hero', 'Special', 'Legendary' ]: common_crew_info.append( ' - any unique & above crew that costs minerals is probably worth buying (just blend it if you don\'t need it)!' ) if common_crew_info: result.append(f'{emojis.pss_min_big} {"".join(common_crew_info)}') if hero_crew_info: result.append(f'{emojis.pss_bux} {hero_crew_info[0]}') else: result.append('-') return result
async def _get_sale_msg_from_data_as_text(raw_data: dict, chars_data: entity.EntitiesData, collections_data: entity.EntitiesData, items_data: entity.EntitiesData, rooms_data: entity.EntitiesData, trainings_data: entity.EntitiesData) -> List[str]: # 'SaleItemMask': use lookups.SALE_ITEM_MASK_LOOKUP to print which item to buy result = [f'{emojis.pss_sale} **Sale**'] sale_items = core.convert_iap_options_mask(int(raw_data['SaleItemMask'])) sale_quantity = raw_data['SaleQuantity'] result.append(f'Buy a {sale_items} _of Starbux_ and get:') sale_type = raw_data['SaleType'] sale_argument = raw_data['SaleArgument'] if sale_type == 'Character': char_details = crew.get_char_details_by_id(sale_argument, chars_data, collections_data) entity_details = ''.join(await char_details.get_details_as_text(entity.EntityDetailsType.SHORT)) elif sale_type == 'Item': item_details = item.get_item_details_by_id(sale_argument, items_data, trainings_data) entity_details = ''.join(await item_details.get_details_as_text(entity.EntityDetailsType.SHORT)) elif sale_type == 'Room': room_details = room.get_room_details_by_id(sale_argument, rooms_data, None, None, None) entity_details = ''.join(await room_details.get_details_as_text(entity.EntityDetailsType.SHORT)) elif sale_type == 'Bonus': entity_details = f'{sale_argument} % bonus starbux' else: # Print debugging info sale_title = raw_data['SaleTitle'] debug_details = [] debug_details.append(f'Sale Type: {sale_type}') debug_details.append(f'Sale Argument: {sale_argument}') debug_details.append(f'Sale Title: {sale_title}') entity_details = '\n'.join(debug_details) result.append(f'{sale_quantity} x {entity_details}') return result
async def _get_shop_msg_from_data_as_text(raw_data: dict, chars_data: entity.EntitiesData, collections_data: entity.EntitiesData, items_data: entity.EntitiesData, rooms_data: entity.EntitiesData, trainings_data: entity.EntitiesData) -> List[str]: result = [f'{emojis.pss_shop} **Shop**'] shop_type = raw_data['LimitedCatalogType'] currency_type = raw_data['LimitedCatalogCurrencyType'] currency_emoji = lookups.CURRENCY_EMOJI_LOOKUP[currency_type.lower()] price = raw_data['LimitedCatalogCurrencyAmount'] can_own_max = raw_data['LimitedCatalogMaxTotal'] entity_id = raw_data['LimitedCatalogArgument'] entity_details = [] if shop_type == 'Character': char_details = crew.get_char_details_by_id(entity_id, chars_data, collections_data) entity_details = await char_details.get_details_as_text(entity.EntityDetailsType.SHORT) elif shop_type == 'Item': item_details = item.get_item_details_by_id(entity_id, items_data, trainings_data) entity_details = await item_details.get_details_as_text(entity.EntityDetailsType.SHORT) elif shop_type == 'Room': room_details = room.get_room_details_by_id(entity_id, rooms_data, None, None, None) entity_details = await room_details.get_details_as_text(entity.EntityDetailsType.SHORT) else: result.append('-') return result if entity_details: result.extend(entity_details) result.append(f'Cost: {price} {currency_emoji}') result.append(f'Can own (max): {can_own_max}') return result
async def __get_shop_msg_from_info_as_text( daily_info: EntityInfo, chars_data: EntitiesData, collections_data: EntitiesData, items_data: EntitiesData, rooms_data: EntitiesData, trainings_data: EntitiesData) -> Tuple[List[str], str]: result = [f'{emojis.pss_shop} **Shop**'] shop_type = daily_info['LimitedCatalogType'] currency_type = daily_info['LimitedCatalogCurrencyType'] currency_emoji = lookups.CURRENCY_EMOJI_LOOKUP.get(currency_type.lower(), currency_type) price = daily_info['LimitedCatalogCurrencyAmount'] can_own_max = daily_info['LimitedCatalogMaxTotal'] entity_id = daily_info['LimitedCatalogArgument'] entity_details_txt = [] if shop_type == 'Character': char_details = crew.get_char_details_by_id(entity_id, chars_data, collections_data) entity_details_txt = await char_details.get_details_as_text( entity.EntityDetailsType.SHORT) sprite_id = char_details.entity_info.get('ProfileSpriteId') elif shop_type == 'Item': item_details = item.get_item_details_by_id(entity_id, items_data, trainings_data) entity_details_txt = await item_details.get_details_as_text( entity.EntityDetailsType.SHORT) logo_sprite_id = item_details.entity_info.get('LogoSpriteId') image_sprite_id = item_details.entity_info.get('ImageSpriteId') sprite_id = logo_sprite_id if logo_sprite_id != image_sprite_id else None elif shop_type == 'Room': room_details = room.get_room_details_by_id(entity_id, rooms_data, None, None, None) entity_details_txt = await room_details.get_details_as_text( entity.EntityDetailsType.SHORT) sprite_id = room_details.entity_info.get('ImageSpriteId') else: result.append('-') return result, None if entity_details_txt: result.extend(entity_details_txt) sprite_id = sprite_id if entity.entity_property_has_value( sprite_id) else None result.append(f'Cost: {price} {currency_emoji}') result.append(f'Can own (max): {can_own_max}') return result, sprite_id
async def __get_event_reward( change_type: str, change_argument: str, chars_data: EntitiesData, collections_data: EntitiesData, items_data: EntitiesData, for_embed: Optional[bool] = False) -> Optional[str]: if for_embed is None: for_embed = False result = None reward_amount = None reward_details = None if entity.entity_property_has_value(change_argument): entity_type, entity_id, reward_amount, _ = utils.parse.entity_string( change_argument, default_amount=None) if entity_type == 'character': reward_details = crew.get_char_details_by_id( entity_id, chars_data, collections_data) elif entity_type == 'item': reward_details = item.get_item_details_by_id( entity_id, items_data, None) else: reward_amount = int(change_argument) if reward_details: details_text = "".join(await reward_details.get_details_as_text( entity.EntityDetailsType.MINI, for_embed=for_embed)) if reward_amount: result = f'{reward_amount}x {details_text}' else: result = details_text elif change_type == 'AddLeagueBonusGas': result = f'{reward_amount+100} % league bonus for {emojis.pss_gas_big}' elif change_type == 'AddEXP': result = f'{reward_amount} % exp from battles' else: result = change_argument return result
async def __process_db_sales_infos( db_sales_infos: List[Dict[str, Any]], utc_now: datetime, filter_old: bool = True) -> List[Dict[str, Any]]: chars_data = await crew.characters_designs_retriever.get_data_dict3() collections_data = await crew.collections_designs_retriever.get_data_dict3( ) items_data = await item.items_designs_retriever.get_data_dict3() researches_data = await research.researches_designs_retriever.get_data_dict3( ) rooms_data = await room.rooms_designs_retriever.get_data_dict3() rooms_designs_sprites_data = await room.rooms_designs_sprites_retriever.get_data_dict3( ) trainings_data = await training.trainings_designs_retriever.get_data_dict3( ) result = [] for db_sales_info in db_sales_infos: expiry_date: datetime = db_sales_info['limitedcatalogexpirydate'] if expiry_date.date() > utc_now.date(): continue expires_in = 30 - (utc_now - expiry_date).days if filter_old and expires_in < 1: continue entity_id = db_sales_info['limitedcatalogargument'] entity_type = db_sales_info['limitedcatalogtype'] currency_type = db_sales_info['limitedcatalogcurrencytype'] currency = lookups.CURRENCY_EMOJI_LOOKUP[currency_type.lower()] currency_amount = db_sales_info['limitedcatalogcurrencyamount'] price = int(currency_amount * 1.25) if entity_type == 'Character': entity_details = crew.get_char_details_by_id( str(entity_id), chars_data, collections_data) entity_name = entity_details.entity_info.get( crew.CHARACTER_DESIGN_DESCRIPTION_PROPERTY_NAME) entity_type = 'Crew' elif entity_type == 'Item': entity_details = item.get_item_details_by_id( str(entity_id), items_data, trainings_data) entity_name = entity_details.entity_info.get( item.ITEM_DESIGN_DESCRIPTION_PROPERTY_NAME) elif entity_type == 'Room': entity_details = room.get_room_details_by_id( str(entity_id), rooms_data, items_data, researches_data, rooms_designs_sprites_data) entity_name = entity_details.entity_info.get( room.ROOM_DESIGN_DESCRIPTION_PROPERTY_NAME) else: entity_details = None entity_name = '' result.append({ 'name': entity_name, 'type': entity_type, 'price': price, 'original_price': currency_amount, 'currency': currency, 'original_currency': currency_type, 'expiry_date': expiry_date, 'expires_in': expires_in, 'entity_details': entity_details }) return result