big_set = research_infos_count > 3 for research_design_details in research_designs_details: if big_set: lines.extend(research_design_details.get_details_as_text_short()) else: lines.extend(research_design_details.get_details_as_text_long()) lines.append(settings.EMPTY_LINE) return lines def _get_key_for_research_sort(research_info: dict, researches_designs_data: dict) -> str: result = '' parent_infos = _get_parents(research_info, researches_designs_data) if parent_infos: for parent_info in parent_infos: result += parent_info[RESEARCH_DESIGN_KEY_NAME].zfill(4) result += research_info[RESEARCH_DESIGN_KEY_NAME].zfill(4) return result # ---------- Initilization ---------- researches_designs_retriever = entity.EntityDesignsRetriever( RESEARCH_DESIGN_BASE_PATH, RESEARCH_DESIGN_KEY_NAME, RESEARCH_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='ResearchDesigns')
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.EntityDesignsRetriever = entity.EntityDesignsRetriever( ACHIEVEMENT_DESIGN_BASE_PATH, ACHIEVEMENT_DESIGN_KEY_NAME, ACHIEVEMENT_DESIGN_DESCRIPTION_PROPERTY_NAME, 'AchievementDesigns' )
for i, promotion_details in enumerate(promotion_design_details): if promotion_details_count > 2: lines.extend(promotion_details.get_details_as_text_short()) else: lines.extend(promotion_details.get_details_as_text_long()) if i < promotion_details_count - 1: lines.append(settings.EMPTY_LINE) return lines # ---------- Initilization ---------- promotion_designs_retriever = entity.EntityDesignsRetriever( PROMOTION_DESIGN_BASE_PATH, PROMOTION_DESIGN_KEY_NAME, PROMOTION_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='PromotionDesigns') # ---------- Testing ---------- #if __name__ == '__main__': # test_promotions = ['alpaco'] # for promotion_name in test_promotions: # os.system('clear') # result = await get_promotions_designs_info_by_name(promotion_name, as_embed=False) # for line in result[0]: # print(line) # print('') # result = ''
chance_name = f'{stat_name}Chance' if chance_name in training_info.keys(): stat_chance = int(training_info[chance_name]) if stat_chance > 0: stat_emoji = lookups.STAT_EMOJI_LOOKUP[stat_name] stat_unit = lookups.STAT_UNITS_LOOKUP[stat_name] operator = '' if guaranteed else '\u2264' return (stat_emoji, operator, stat_chance, stat_unit) 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}' def _get_room_names(rank: int) -> Tuple[str, str]: if rank in lookups.TRAINING_RANK_ROOM_LOOKUP.keys(): return lookups.TRAINING_RANK_ROOM_LOOKUP[rank] else: return (None, None) # ---------- Initilization ---------- trainings_designs_retriever = entity.EntityDesignsRetriever( TRAINING_DESIGN_BASE_PATH, TRAINING_DESIGN_KEY_NAME, TRAINING_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='TrainingDesigns', sorted_key_function=_get_key_for_training_sort)
async def init(): global rooms_designs_retriever global rooms_designs_purchases_retriever rooms_designs_retriever = entity.EntityDesignsRetriever( ROOM_DESIGN_BASE_PATH, ROOM_DESIGN_KEY_NAME, ROOM_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='RoomDesigns', sorted_key_function=_get_key_for_room_sort) rooms_designs_purchases_retriever = entity.EntityDesignsRetriever( ROOM_DESIGN_PURCHASE_BASE_PATH, ROOM_DESIGN_PURCHASE_KEY_NAME, ROOM_DESIGN_PURCHASE_DESCRIPTION_PROPERTY_NAME, cache_name='RoomDesignPurchases') global __allowed_room_names rooms_designs_data = await rooms_designs_retriever.get_data_dict3() __allowed_room_names = sorted( __get_allowed_room_short_names(rooms_designs_data)) global __room_details_properties __room_details_properties = [ ('Name', False, [ ROOM_DESIGN_DESCRIPTION_PROPERTY_NAME, ROOM_DESIGN_DESCRIPTION_PROPERTY_NAME_2, ROOM_DESIGN_TYPE_PROPERTY_NAME ], _get_room_name, []), ('Description', False, ['RoomDescription'], _get_description, []), ('Size (WxH)', True, ['Columns', 'Rows'], _get_room_size, []), ('Max power used', True, ['MaxSystemPower'], _get_value, []), ('Power generated', True, ['MaxPowerGenerated'], _get_value, []), ('Innate armor', True, ['DefaultDefenceBonus'], _get_innate_armor, []), ('Enhanced By', True, ['EnhancementType'], _get_value, []), ('Min hull lvl', True, ['MinShipLevel'], _get_value, []), ('Reload (Speed)', True, ['ReloadTime'], _get_reload_time, []), ('Shots fired', True, ['MissileDesign.Volley', 'MissileDesign.VolleyDelay'], _get_shots_fired, []), ('System dmg', True, [ 'MissileDesign.SystemDamage', 'ReloadTime', 'MaxSystemPower', 'MissileDesign.Volley', 'MissileDesign.VolleyDelay', False ], _get_dmg_for_dmg_type, []), ('Shield dmg', True, [ 'MissileDesign.ShieldDamage', 'ReloadTime', 'MaxSystemPower', 'MissileDesign.Volley', 'MissileDesign.VolleyDelay', False ], _get_dmg_for_dmg_type, []), ('Crew dmg', True, [ 'MissileDesign.CharacterDamage', 'ReloadTime', 'MaxSystemPower', 'MissileDesign.Volley', 'MissileDesign.VolleyDelay', False ], _get_dmg_for_dmg_type, []), ('Hull dmg', True, [ 'MissileDesign.HullDamage', 'ReloadTime', 'MaxSystemPower', 'MissileDesign.Volley', 'MissileDesign.VolleyDelay', False ], _get_dmg_for_dmg_type, []), ('Direct System dmg', True, [ 'MissileDesign.DirectSystemDamage', 'ReloadTime', 'MaxSystemPower', 'MissileDesign.Volley', 'MissileDesign.VolleyDelay', True ], _get_dmg_for_dmg_type, []), ('EMP duration', True, ['MissileDesign.EMPLength'], _get_emp_length, []), ('Max storage', True, [ 'Capacity', 'ManufactureCapacity', 'ManufactureRate', 'ManufactureType', ROOM_DESIGN_TYPE_PROPERTY_NAME ], _get_max_storage_and_type, []), ('Cap per tick', True, ['Capacity', ROOM_DESIGN_TYPE_PROPERTY_NAME], _get_capacity_per_tick, CAPACITY_PER_TICK_UNITS.keys()), ('Cooldown', True, ['CooldownTime'], _get_cooldown, []), ('Queue limit', True, ['Capacity', 'ManufactureCapacity', 'ManufactureRate'], _get_queue_limit, []), ('Manufacture speed', True, ['ManufactureRate'], _get_manufacture_rate, []), ('Gas per crew', True, ['ManufactureRate'], _get_value, ['Recycling']), ('Max crew blend', True, ['ManufactureCapacity'], _get_value, ['Recycling']), ('Build time', True, ['ConstructionTime'], _get_build_time, []), ('Build cost', True, ['PriceString'], _get_build_cost, []), ('Build requirement', True, ['RequirementString'], _get_build_requirement, []), ('Grid types', True, ['SupportedGridTypes'], _get_is_allowed_in_extension_grids, []), ('More info', True, ['Flags'], _convert_room_flags, []) ] # ---------- Testing ---------- #if __name__ == '__main__': # test_rooms = ['ion'] # for room_name in test_rooms: # os.system('clear') # result = await get_room_details_from_name(room_name, as_embed=False) # for line in result[0]: # print(line) # result = ''
def _get_best_title(stat: str, slot: str) -> str: return f'Best **{stat}** bonus for **{slot}** slot' def _get_pretty_slot(slot: str) -> str: return slot.replace('Equipment', '') # ---------- Initilization ---------- NOT_ALLOWED_ITEM_NAMES: List[str] = ['AI', 'I', 'II', 'III', 'IV', 'V', 'VI'] ALLOWED_ITEM_NAMES: List[str] = [] items_designs_retriever: entity.EntityDesignsRetriever = entity.EntityDesignsRetriever( ITEM_DESIGN_BASE_PATH, ITEM_DESIGN_KEY_NAME, ITEM_DESIGN_DESCRIPTION_PROPERTY_NAME, 'ItemsDesigns', fix_data_delegate=_fix_item_name) __properties: Dict[str, Union[ entity.EntityDesignDetailProperty, List[entity.EntityDesignDetailProperty]]] = { 'title': entity.EntityDesignDetailProperty( 'Title', False, entity_property_name=ITEM_DESIGN_DESCRIPTION_PROPERTY_NAME), 'description': entity.EntityDesignDetailProperty('Description', False, transform_function=__get_rarity), 'base': [
return result # ---------- Initilization ---------- character_designs_retriever = entity.EntityDesignsRetriever( CHARACTER_DESIGN_BASE_PATH, CHARACTER_DESIGN_KEY_NAME, CHARACTER_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='CharacterDesigns' ) collection_designs_retriever = entity.EntityDesignsRetriever( COLLECTION_DESIGN_BASE_PATH, COLLECTION_DESIGN_KEY_NAME, COLLECTION_DESIGN_DESCRIPTION_PROPERTY_NAME, cache_name='CollectionDesigns' )
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.EntityDesignsRetriever( 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)
#!/usr/bin/env python # -*- coding: UTF-8 -*- import pss_entity as entity # ---------- Constants ---------- STARSYSTEM_DESIGN_BASE_PATH = 'GalaxyService/ListStarSystems?languageKey=en' STARSYSTEM_DESIGN_KEY_NAME = 'StarSystemId' 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.EntityDesignsRetriever = entity.EntityDesignsRetriever( STARSYSTEM_DESIGN_BASE_PATH, STARSYSTEM_DESIGN_KEY_NAME, STARSYSTEM_DESIGN_DESCRIPTION_PROPERTY_NAME, 'StarSystemDesigns') star_system_links_designs_retriever: entity.EntityDesignsRetriever = entity.EntityDesignsRetriever( STARSYSTEMLINK_DESIGN_BASE_PATH, STARSYSTEMLINK_DESIGN_KEY_NAME, STARSYSTEMLINK_DESIGN_DESCRIPTION_PROPERTY_NAME, 'StarSystemLinkDesigns')