Beispiel #1
0
def get_research_details_by_id(research_design_id: str, researches_data: EntitiesData) -> entity.EntityDetails:
    if research_design_id:
        if research_design_id and research_design_id in researches_data.keys():
            research_info = researches_data[research_design_id]
            research_details = __create_research_details_from_info(research_info, researches_data)
            return research_details
    return None
Beispiel #2
0
def get_entity_details_by_id(
        entity_design_id: str,
        entities_data: EntitiesData) -> entity.EntityDetails:
    if entity_design_id:
        if entity_design_id and entity_design_id in entities_data.keys():
            return __create_entity_details_from_info(
                entities_data[entity_design_id], entities_data)
    return None
Beispiel #3
0
def get_item_details_by_id(
        item_design_id: str, items_data: EntitiesData,
        trainings_data: EntitiesData) -> entity.EntityDetails:
    if item_design_id and item_design_id in items_data.keys():
        return __create_base_details_from_info(items_data[item_design_id],
                                               items_data, trainings_data)
    else:
        return None
Beispiel #4
0
def get_event_details_by_id(
        situation_design_id: str,
        situations_data: EntitiesData) -> entity.EntityDetails:
    if situation_design_id:
        if situation_design_id and situation_design_id in situations_data.keys(
        ):
            return __create_situation_details_from_info(
                situations_data[situation_design_id], situations_data)
    return None
Beispiel #5
0
def __get_item_infos_by_name(
        item_name: str,
        items_data: EntitiesData,
        return_best_match: bool = False) -> List[EntityInfo]:
    item_design_ids = __get_item_design_ids_from_name(item_name, items_data)
    result = [
        items_data[item_design_id] for item_design_id in item_design_ids
        if item_design_id in items_data.keys()
    ]

    if result:
        get_best_match = return_best_match or utils.is_str_in_list(
            item_name, ALLOWED_ITEM_NAMES, case_sensitive=False
        ) and len(item_name) < settings.MIN_ENTITY_NAME_LENGTH - 1
        if get_best_match:
            result = [result[0]]

    return result
Beispiel #6
0
    async def get_entities_infos_by_name(
        self,
        entity_name: str,
        entities_data: EntitiesData = None,
        sorted_key_function: Callable[[dict, dict], str] = None
    ) -> List[Dict[str, object]]:
        entities_data = entities_data or await self.get_data_dict3()
        sorted_key_function = sorted_key_function or self.__sorted_key_function

        entity_ids = await self.get_entities_ids_by_name(
            entity_name, entities_data=entities_data)
        entities_data_keys = entities_data.keys()
        result = [
            entities_data[entity_id] for entity_id in entity_ids
            if entity_id in entities_data_keys
        ]
        if sorted_key_function is not None:
            result = sorted(result,
                            key=lambda entity_info:
                            (sorted_key_function(entity_info, entities_data)))

        return result
Beispiel #7
0
async def get_fleet_users_stars_from_tournament_data(
        ctx,
        fleet_info: EntityInfo,
        fleet_data: EntitiesData,
        user_data: EntitiesData,
        retrieved_date: datetime,
        max_tourney_battle_attempts: Optional[int] = None,
        as_embed: bool = settings.USE_EMBEDS) -> Union[List[Embed], List[str]]:
    fleet_id = fleet_info[FLEET_KEY_NAME]
    fleet_users_infos = {}
    if fleet_id in fleet_data.keys():
        fleet_info[top.DIVISION_DESIGN_KEY_NAME] = fleet_data[fleet_id][
            top.DIVISION_DESIGN_KEY_NAME]
        fleet_users_infos = dict({
            user_info[USER_KEY_NAME]: user_info
            for user_info in user_data.values()
            if user_info[FLEET_KEY_NAME] == fleet_id
        })
    return await get_fleet_users_stars_from_info(ctx,
                                                 fleet_info,
                                                 fleet_users_infos,
                                                 max_tourney_battle_attempts,
                                                 retrieved_at=retrieved_date,
                                                 as_embed=as_embed)
Beispiel #8
0
def get_char_details_by_id(char_design_id: str, chars_data: EntitiesData, collections_data: EntitiesData, level: int = None) -> entity.entity.EntityDetails:
    if char_design_id:
        if char_design_id and char_design_id in chars_data.keys():
            return __create_character_details_from_info(chars_data[char_design_id], chars_data, collections_data, level)
    return None
Beispiel #9
0
def __get_members_count_display_name(collection_info: EntityInfo, collections_data: EntitiesData, characters_data: EntitiesData, **kwargs) -> Optional[str]:
    collection_id = collection_info[COLLECTION_DESIGN_KEY_NAME]
    chars_designs_infos = [characters_data[char_id] for char_id in characters_data.keys() if characters_data[char_id][COLLECTION_DESIGN_KEY_NAME] == collection_id]
    result = f'Members ({len(chars_designs_infos)})'
    return result
Beispiel #10
0
def __get_collection_member_names(collection_info: EntityInfo, collections_data: EntitiesData, characters_data: EntitiesData, **kwargs) -> Optional[str]:
    collection_id = collection_info[COLLECTION_DESIGN_KEY_NAME]
    chars_designs_infos = [characters_data[char_id] for char_id in characters_data.keys() if characters_data[char_id][COLLECTION_DESIGN_KEY_NAME] == collection_id]
    result = [char_info[CHARACTER_DESIGN_DESCRIPTION_PROPERTY_NAME] for char_info in chars_designs_infos]
    result.sort()
    return ', '.join(result)
Beispiel #11
0
def __get_collection_member_count(collection_info: EntityInfo, collections_data: EntitiesData, characters_data: EntitiesData, **kwargs) -> Optional[str]:
    collection_id = collection_info[COLLECTION_DESIGN_KEY_NAME]
    chars_designs_infos = [characters_data[char_id] for char_id in characters_data.keys() if characters_data[char_id][COLLECTION_DESIGN_KEY_NAME] == collection_id]
    result = len(chars_designs_infos)
    return f'{result} members'