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_merchantship_msg_from_info_as_text( daily_info: EntityInfo, items_data: EntitiesData, trainings_data: EntitiesData) -> List[str]: result = [f'{emojis.pss_merchantship} **Merchant ship**'] if daily_info: cargo_items = daily_info['CargoItems'].split('|') cargo_prices = daily_info['CargoPrices'].split('|') for i, cargo_info in enumerate(cargo_items): _, item_id, amount, _ = utils.parse.entity_string(cargo_info) if item_id: item_details = item.get_item_details_by_id( item_id, items_data, trainings_data) item_details = ''.join(await item_details.get_details_as_text( entity.EntityDetailsType.SHORT)) currency_type, currency_id, currency_amount, _ = utils.parse.entity_string( cargo_prices[i]) currency_type = currency_type.lower() if 'item' in currency_type: key = f'item{currency_id}' currency = lookups.get_lookup_value_or_default( lookups.CURRENCY_EMOJI_LOOKUP, key) if not currency: currency_item_details = item.get_item_details_by_id( currency_id, items_data, trainings_data) currency = ''.join( await currency_item_details.get_details_as_text( entity.EntityDetailsType.MINI)) else: currency_amount = currency_id currency = lookups.get_lookup_value_or_default( lookups.CURRENCY_EMOJI_LOOKUP, currency_type, default=currency_type) result.append( f'{amount} x {item_details}: {currency_amount} {currency}') else: result.append('-') 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_daily_reward_from_data_as_text(raw_data: dict, item_data: entity.EntitiesData, trainings_data: entity.EntitiesData) -> List[str]: result = ['**Daily rewards**'] reward_currency = raw_data['DailyRewardType'].lower() reward_currency_emoji = lookups.CURRENCY_EMOJI_LOOKUP[reward_currency] reward_amount = int(raw_data['DailyRewardArgument']) reward_amount, reward_multiplier = util.get_reduced_number(reward_amount) result.append(f'{reward_amount:.0f}{reward_multiplier} {reward_currency_emoji}') item_rewards = raw_data['DailyItemRewards'].split('|') for item_reward in item_rewards: item_id, amount = item_reward.split('x') item_details: entity.EntityDetails = item.get_item_details_by_id(item_id, item_data, trainings_data) item_details_text = ''.join(await item_details.get_details_as_text(entity.EntityDetailsType.SHORT)) result.append(f'{amount} x {item_details_text}') return result
async def _get_merchantship_msg_from_data_as_text(raw_data: dict, items_data: entity.EntitiesData, trainings_data: entity.EntitiesData) -> List[str]: result = [f'{emojis.pss_merchantship} **Merchant ship**'] if raw_data: cargo_items = raw_data['CargoItems'].split('|') cargo_prices = raw_data['CargoPrices'].split('|') for i, cargo_info in enumerate(cargo_items): if 'x' in cargo_info: item_id, amount = cargo_info.split('x') else: item_id = cargo_info amount = '1' if ':' in item_id: _, item_id = item_id.split(':') if item_id: item_details = item.get_item_details_by_id(item_id, items_data, trainings_data) item_details = ''.join(await item_details.get_details_as_text(entity.EntityDetailsType.SHORT)) currency_type, price = cargo_prices[i].split(':') currency_emoji = lookups.CURRENCY_EMOJI_LOOKUP[currency_type.lower()] result.append(f'{amount} x {item_details}: {price} {currency_emoji}') else: result.append('-') return result
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