get_entity_details_function = REWARD_TYPE_GET_ENTITY_FUNCTIONS[ entity_type.lower()] if get_entity_details_function: intermediate = [] for entity_id in rewards[entity_type]: entity_details: entity.LegacyEntityDetails = get_entity_details_function( entity_id) intermediate.append(entity_details.get_details_as_text_short()) result.append(', '.join(intermediate)) else: result.append(f'{entity_type}: {sum(rewards[entity_type])}') return ', '.join(result) def _get_requirement_type_and_value(requirement_string: str, separator: str, add_to_value: int = 0) -> (str, int): requirement_type, requirement_value = requirement_string.split(separator) requirement_value = int(requirement_value) + add_to_value return requirement_type, requirement_value # ---------- Initilization ---------- promotion_designs_retriever = entity.EntityRetriever( PROMOTION_DESIGN_BASE_PATH, PROMOTION_DESIGN_KEY_NAME, PROMOTION_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='PromotionDesigns')
return result def __create_top_embeds(title: str, body_lines: List[str], colour: Colour) -> List[Embed]: bodies = utils.discord.create_posts_from_lines( body_lines, utils.discord.MAXIMUM_CHARACTERS_EMBED_DESCRIPTION) result = [] for body in bodies: result.append( utils.discord.create_embed(title, description=body, colour=colour)) return result def __get_fleet_division_designs( divisions_designs_data: EntitiesData) -> EntitiesData: result = { key: value for key, value in divisions_designs_data.items() if value.get('DivisionType') == 'Fleet' } return result # ---------- Initilization ---------- divisions_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( DIVISION_DESIGN_BASE_PATH, DIVISION_DESIGN_KEY_NAME, DIVISION_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='DivisionDesigns')
import pss_login as login import pss_lookups as lookups import settings import utility as util # ---------- Constants ---------- SHIP_DESIGN_BASE_PATH = 'ShipService/ListAllShipDesigns2?languageKey=en' SHIP_DESIGN_KEY_NAME = 'ShipDesignId' SHIP_DESIGN_DESCRIPTION_PROPERTY_NAME = 'ShipDesignName' # ---------- Initilization ---------- ships_designs_retriever = entity.EntityRetriever( SHIP_DESIGN_BASE_PATH, SHIP_DESIGN_KEY_NAME, SHIP_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='ShipDesigns') __ship_designs_cache = PssCache(SHIP_DESIGN_BASE_PATH, 'ShipDesigns', SHIP_DESIGN_KEY_NAME, update_interval=60) # ---------- Helper functions ---------- async def get_inspect_ship_for_user(user_id: str) -> (dict, dict): inspect_ship_path = await _get_inspect_ship_base_path(user_id) inspect_ship_data = await core.get_data_from_path(inspect_ship_path) result = core.xmltree_to_dict2(inspect_ship_data) return result.get('User', None), result.get('Ship', None)
if start_at <= utc_now and end_at > utc_now: situation_info['from_date'] = from_date situation_info['end_date'] = end_date result.append(situation_info) result = sorted( result, key=lambda x: (x['end_date'], x['from_date'], int(x[SITUATION_DESIGN_KEY_NAME])), reverse=True) return result # ---------- Initilization ---------- situations_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( SITUATION_DESIGN_BASE_PATH, SITUATION_DESIGN_KEY_NAME, SITUATION_DESIGN_DESCRIPTION_PROPERTY_NAME, 'SituationDesigns') __properties: entity.EntityDetailsCreationPropertiesCollection = { 'title': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty( 'Title', False, omit_if_none=False, entity_property_name=SITUATION_DESIGN_DESCRIPTION_PROPERTY_NAME)), 'description': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty( 'Description', False,
char_1_info['Prestige'] = [characters_data[char_2_id] for char_2_id in chars_2_ids] result.append(char_1_info) return result # ---------- Initilization ---------- __prestige_from_cache_dict = {} __prestige_to_cache_dict = {} characters_designs_retriever = entity.EntityRetriever( CHARACTER_DESIGN_BASE_PATH, CHARACTER_DESIGN_KEY_NAME, CHARACTER_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='CharacterDesigns' ) collections_designs_retriever = entity.EntityRetriever( COLLECTION_DESIGN_BASE_PATH, COLLECTION_DESIGN_KEY_NAME, COLLECTION_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='CollectionDesigns' ) __properties: entity.EntityDetailsCreationPropertiesCollection = { 'character_title': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty('Title', False, omit_if_none=False, transform_function=__get_name_with_level)
return None def __get_stat_chance_as_text(stat_emoji: str, operator: str, stat_chance: str, stat_unit: str) -> str: return f'{stat_emoji} {operator}{stat_chance}{stat_unit}' # ---------- Initilization ---------- trainings_designs_retriever = entity.EntityRetriever( TRAINING_DESIGN_BASE_PATH, TRAINING_DESIGN_KEY_NAME, TRAINING_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='TrainingDesigns', sorted_key_function=__get_key_for_training_sort ) __properties: entity.EntityDetailsCreationPropertiesCollection = { 'title': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty('Title', False, omit_if_none=False, entity_property_name=TRAINING_DESIGN_DESCRIPTION_PROPERTY_NAME), property_mini=entity.NO_PROPERTY ), 'description': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty('Description', False, omit_if_none=False, entity_property_name='TrainingDescription'), property_short=entity.NO_PROPERTY ), 'properties': entity.EntityDetailPropertyListCollection([ entity.EntityDetailProperty('Duration', True, transform_function=__get_duration),
__create_entity_details_from_info(entity_info, entities_data) for entity_info in entities_designs_infos ] result = entity.EntityDetailsCollection(entities_details, big_set_threshold=3) # ---------- DB ---------- # ---------- Mocks ---------- # ---------- Initilization ---------- entities_designs_retriever = entity.EntityRetriever( ENTITY_DESIGN_BASE_PATH, ENTITY_DESIGN_KEY_NAME, ENTITY_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='EntityDesigns') __properties: entity.EntityDetailsCreationPropertiesCollection = { 'title': entity.EntityDetailPropertyCollection(entity.EntityDetailProperty( 'Title', False, omit_if_none=False, entity_property_name='', transform_function=None), property_long=entity.NO_PROPERTY, property_short=entity.NO_PROPERTY, property_mini=entity.NO_PROPERTY), 'description':
import pss_entity as entity from typehints import EntitiesData, EntityInfo # ---------- Constants ---------- CRAFT_DESIGN_BASE_PATH: str = 'RoomService/ListCraftDesigns?languageKey=en' CRAFT_DESIGN_DESCRIPTION_PROPERTY_NAME: str = 'CraftName' CRAFT_DESIGN_KEY_NAME: str = 'CraftDesignId' # ---------- Initialization ---------- crafts_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( CRAFT_DESIGN_BASE_PATH, CRAFT_DESIGN_KEY_NAME, CRAFT_DESIGN_DESCRIPTION_PROPERTY_NAME, 'CraftDesigns')
STARSYSTEM_DESIGN_DESCRIPTION_PROPERTY_NAME = 'StarSystemTitle' STARSYSTEMLINK_DESIGN_BASE_PATH = 'GalaxyService/ListStarSystems?languageKey=en' STARSYSTEMLINK_DESIGN_KEY_NAME = 'StarSystemId' STARSYSTEMLINK_DESIGN_DESCRIPTION_PROPERTY_NAME = 'StarSystemTitle' # ---------- Initialization ---------- star_systems_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( STARSYSTEM_DESIGN_BASE_PATH, STARSYSTEM_DESIGN_KEY_NAME, STARSYSTEM_DESIGN_DESCRIPTION_PROPERTY_NAME, 'StarSystemDesigns' ) star_system_links_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( STARSYSTEMLINK_DESIGN_BASE_PATH, STARSYSTEMLINK_DESIGN_KEY_NAME, STARSYSTEMLINK_DESIGN_DESCRIPTION_PROPERTY_NAME, 'StarSystemLinkDesigns' )
parent_research_design_id = None if parent_research_design_id is not None: parent_info = researches_data[parent_research_design_id] result = _get_parents(parent_info, researches_data) result.append(parent_info) return result else: return [] # ---------- Initilization ---------- researches_designs_retriever = entity.EntityRetriever( RESEARCH_DESIGN_BASE_PATH, RESEARCH_DESIGN_KEY_NAME, RESEARCH_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='ResearchDesigns') __properties = { 'title': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty( 'Title', False, omit_if_none=False, entity_property_name=RESEARCH_DESIGN_DESCRIPTION_PROPERTY_NAME)), 'description': entity.EntityDetailPropertyCollection(entity.EntityDetailProperty( 'Description', False,
# ---------- Constants ---------- ACTION_TYPE_DESIGN_BASE_PATH: str = 'RoomService/ListActionTypes2?languageKey=en' ACTION_TYPE_DESIGN_DESCRIPTION_PROPERTY_NAME: str = 'ActionTypeName' ACTION_TYPE_DESIGN_KEY_NAME: str = 'ActionTypeId' CONDITION_TYPE_DESIGN_BASE_PATH: str = 'RoomService/ListConditionTypes2?languageKey=en' CONDITION_TYPE_DESIGN_DESCRIPTION_PROPERTY_NAME: str = 'ConditionTypeName' CONDITION_TYPE_DESIGN_KEY_NAME: str = 'ConditionTypeId' # ---------- Initialization ---------- action_types_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( ACTION_TYPE_DESIGN_BASE_PATH, ACTION_TYPE_DESIGN_KEY_NAME, ACTION_TYPE_DESIGN_DESCRIPTION_PROPERTY_NAME, 'ActionTypeDesigns' ) condition_types_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( CONDITION_TYPE_DESIGN_BASE_PATH, CONDITION_TYPE_DESIGN_KEY_NAME, CONDITION_TYPE_DESIGN_DESCRIPTION_PROPERTY_NAME, 'ConditionTypeDesigns' )
#!/usr/bin/env python # -*- coding: UTF-8 -*- import pss_entity as entity # ---------- Constants ---------- ACHIEVEMENT_DESIGN_BASE_PATH = 'AchievementService/ListAchievementDesigns2?languageKey=en' ACHIEVEMENT_DESIGN_KEY_NAME = 'AchievementDesignId' ACHIEVEMENT_DESIGN_DESCRIPTION_PROPERTY_NAME = 'AchievementTitle' # ---------- Initialization ---------- achievements_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( ACHIEVEMENT_DESIGN_BASE_PATH, ACHIEVEMENT_DESIGN_KEY_NAME, ACHIEVEMENT_DESIGN_DESCRIPTION_PROPERTY_NAME, 'AchievementDesigns')
#!/usr/bin/env python # -*- coding: UTF-8 -*- import pss_entity as entity # ---------- Constants ---------- MISSION_DESIGN_BASE_PATH = 'MissionService/ListAllMissionDesigns2?languageKey=en' MISSION_DESIGN_KEY_NAME = 'MissionDesignId' MISSION_DESIGN_DESCRIPTION_PROPERTY_NAME = 'MissionTitle' # ---------- Initialization ---------- missions_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( MISSION_DESIGN_BASE_PATH, MISSION_DESIGN_KEY_NAME, MISSION_DESIGN_DESCRIPTION_PROPERTY_NAME, 'MissionDesigns')
item_info, items_data, found_upgrades_for_data=found_upgrades_for_data, no_upgrades_for_data=no_upgrades_for_data, upgrades_infos_count=upgrades_infos_count) for item_info in items_designs_infos ] result = entity.EntityDetailsCollection(price_details, big_set_threshold=1) return result # ---------- Initilization ---------- items_designs_retriever: entity.EntityRetriever = entity.EntityRetriever( ITEM_DESIGN_BASE_PATH, ITEM_DESIGN_KEY_NAME, ITEM_DESIGN_DESCRIPTION_PROPERTY_NAME, 'ItemsDesigns', fix_data_delegate=__fix_item_name) __properties: entity.EntityDetailsCreationPropertiesCollection = { 'title': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty( 'Title', False, omit_if_none=False, entity_property_name=ITEM_DESIGN_DESCRIPTION_PROPERTY_NAME)), 'title_ingredients': entity.EntityDetailPropertyCollection( entity.EntityDetailProperty( 'Title',