Ejemplo n.º 1
0
def __get_user_name_as_text(user_info: entity.EntityDesignInfo) -> str:
    result = None
    user_name = user_info.get('Name')
    if user_name is not None:
        result = user_name
        current_user_name = user_info.get('CurrentName')
        if current_user_name is not None:
            result += f' (now: {current_user_name})'
    return result
Ejemplo n.º 2
0
def __get_name(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    fleet_name = fleet_info.get(FLEET_DESCRIPTION_PROPERTY_NAME)
    if fleet_name is not None:
        result = fleet_name
        current_name = fleet_info.get('CurrentAllianceName')
        if current_name is not None:
            result += f' (now: {current_name})'
    return result
Ejemplo n.º 3
0
def __get_trophies_as_text(user_info: entity.EntityDesignInfo) -> str:
    result = None
    trophies = user_info.get('Trophy')
    if trophies is not None:
        result = f'{trophies}'
        highest_trophies = user_info.get('HighestTrophy')
        if highest_trophies is not None:
            result += f' (highest: {highest_trophies})'
    return result
Ejemplo n.º 4
0
def __get_league_as_text(user_info: entity.EntityDesignInfo) -> str:
    result = None
    trophies = user_info.get('Trophy')
    if trophies is not None:
        result = f'{_get_league_from_trophies(int(trophies))}'
        highest_trophies = user_info.get('HighestTrophy')
        if highest_trophies is not None:
            result += f' (highest: {_get_league_from_trophies(int(highest_trophies))})'
    return result
Ejemplo n.º 5
0
def __get_user_type_as_text(user_info: entity.EntityDesignInfo) -> str:
    result = None
    user_type = user_info.get('UserType')
    if user_type is not None:
        result = lookups.get_lookup_value_or_default(lookups.USER_TYPE,
                                                     user_type)
    return result
Ejemplo n.º 6
0
def __parse_timestamp(user_info: entity.EntityDesignInfo,
                      field_name: str) -> str:
    result = None
    timestamp = user_info.get(field_name)
    if timestamp is not None:
        result = util.parse_pss_datetime(timestamp)
    return result
Ejemplo n.º 7
0
async def __get_fleet_info_by_user_info(
        user_info: entity.EntityDesignInfo) -> entity.EntityDesignInfo:
    result = {}
    fleet_id = user_info.get('AllianceId', '0')
    if fleet_id != '0':
        result = await fleet._get_fleet_info_by_id(fleet_id)
    return result
Ejemplo n.º 8
0
def __get_type_as_text(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    requires_approval = fleet_info.get('RequiresApproval')
    if requires_approval is not None:
        result = lookups.get_lookup_value_or_default(
            lookups.FLEET_TYPE_LOOKUP,
            requires_approval.lower() == 'true')
    return result
Ejemplo n.º 9
0
def __get_ship_status_as_text(ship_info: entity.EntityDesignInfo) -> str:
    result = None
    ship_status = ship_info.get('ShipStatus')
    if ship_status is not None:
        result = lookups.get_lookup_value_or_default(lookups.USER_STATUS,
                                                     ship_status,
                                                     default=ship_status)
    return result
Ejemplo n.º 10
0
def __get_member_count(fleet_info: entity.EntityDesignInfo,
                       fleet_users_infos: entity.EntitiesDesignsData) -> str:
    result = None
    member_count = fleet_info.get('NumberOfMembers')
    if member_count is not None:
        result = member_count
    else:
        result = len(fleet_users_infos)
    return result
Ejemplo n.º 11
0
def get_division_name_as_text(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    if fleet_info:
        division_design_id = fleet_info.get('DivisionDesignId')
        if division_design_id is not None and division_design_id != '0':
            result = lookups.get_lookup_value_or_default(
                lookups.DIVISION_DESIGN_ID_TO_CHAR,
                division_design_id,
                default='-')
    return result
Ejemplo n.º 12
0
def __get_trophies(fleet_info: entity.EntityDesignInfo,
                   fleet_users_infos: entity.EntitiesDesignsData) -> str:
    result = None
    member_count = fleet_info.get('Trophy')
    if member_count is not None:
        result = member_count
    else:
        result = sum(
            int(user_info.get('Trophy', '0'))
            for user_info in fleet_users_infos.values())
    return result
Ejemplo n.º 13
0
def __get_division_name_and_ranking_as_text(
        fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    division_name = get_division_name_as_text(fleet_info)
    if division_name is not None and division_name != '-':
        result = division_name
        ranking = fleet_info.get('Ranking')
        if ranking is not None and ranking != '0':
            division_ranking = int(
                ranking) - lookups.DIVISION_CUTOFF_LOOKUP[division_name][0] + 1
            result += f' ({util.get_ranking(division_ranking)})'
    return result
Ejemplo n.º 14
0
def __get_fleet_name_and_rank_as_text(
        user_info: entity.EntityDesignInfo,
        fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    if fleet_info:
        fleet_name = fleet_info.get(fleet.FLEET_DESCRIPTION_PROPERTY_NAME, '')
        fleet_membership = user_info.get('AllianceMembership')
        fleet_rank = None
        if fleet_membership:
            fleet_rank = lookups.get_lookup_value_or_default(
                lookups.ALLIANCE_MEMBERSHIP,
                fleet_membership,
                default=fleet_membership)
        if fleet_name:
            result = fleet_name
            if fleet_rank:
                result += f' ({fleet_rank})'
        else:
            result = '<data error>'
    else:
        result = '<no fleet>'
    return result
Ejemplo n.º 15
0
def __get_crew_donated_as_text(user_info: entity.EntityDesignInfo,
                               fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    if fleet_info:
        result = user_info.get('CrewDonated')
    return result
Ejemplo n.º 16
0
def __get_description_as_text(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    description = fleet_info.get('AllianceDescription')
    if description is not None:
        result = description.strip()
    return result
Ejemplo n.º 17
0
def __get_stars_as_text(user_info: entity.EntityDesignInfo) -> str:
    result = None
    stars = user_info.get('AllianceScore')
    if stars is not None and stars != '0':
        result = stars
    return result
Ejemplo n.º 18
0
def __get_stars(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    stars = fleet_info.get('Score')
    if stars is not None and stars != '0':
        result = stars
    return result
Ejemplo n.º 19
0
def __get_min_trophies(fleet_info: entity.EntityDesignInfo) -> str:
    result = fleet_info.get('MinTrophyRequired')
    return result
Ejemplo n.º 20
0
def __get_crew_borrowed_as_text(user_info: entity.EntityDesignInfo,
                                fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    if fleet_info:
        result = user_info.get('CrewReceived')
    return result
Ejemplo n.º 21
0
def __get_ranking_as_text(fleet_info: entity.EntityDesignInfo) -> str:
    result = None
    ranking = fleet_info.get('Ranking')
    if ranking is not None and ranking != '0':
        result = util.get_ranking(ranking)
    return result