Skip to content

API Reference

utils

Functions:

Attributes:

  • T

T module-attribute

T = TypeVar('T')

calc_gi_chara_upgrade_stat_values

calc_gi_chara_upgrade_stat_values(
    character: CharacterDetail, level: int, ascended: bool
) -> dict[str, float]

Calculate the stat values of a GI character at a certain level and ascension status.

Parameters:

  • character

    (CharacterDetail) –

    The character to calculate the stats for.

  • level

    (int) –

    The level of the character.

  • ascended

    (bool) –

    Whether the character is ascended.

Returns:

calc_hsr_chara_upgrade_stat_values

calc_hsr_chara_upgrade_stat_values(
    character: CharacterDetail, level: int, ascended: bool
) -> dict[str, float]

Calculate the stat values of an HSR character at a certain level and ascension status.

Parameters:

  • character

    (CharacterDetail) –

    The character to calculate the stats for.

  • level

    (int) –

    The level of the character.

  • ascended

    (bool) –

    Whether the character is ascended.

Returns:

calc_light_cone_upgrade_stat_values

calc_light_cone_upgrade_stat_values(
    light_cone: LightConeDetail, level: int, ascended: bool
) -> dict[str, float]

Calculate the stat values of an HSR light cone at a certain level and ascension status.

Parameters:

  • light_cone

    (LightConeDetail) –

    The light cone to calculate the stats for.

  • level

    (int) –

    The level of the light cone.

  • ascended

    (bool) –

    Whether the light cone is ascended.

Returns:

calc_weapon_upgrade_stat_values

calc_weapon_upgrade_stat_values(
    weapon: WeaponDetail, level: int, ascended: bool
) -> dict[str, float]

Calculate the stat values of a GI weapon at a certain level and ascension.

Parameters:

  • weapon

    (WeaponDetail) –

    The weapon to calculate the stats for.

  • level

    (int) –

    The level of the weapon.

  • ascended

    (bool) –

    Whether the weapon is ascended.

Returns:

cleanup_text

cleanup_text(text: str) -> str

Remove HTML tags and sprite presets from a string.

Parameters:

  • text

    (str) –

    The text to clean.

Returns:

  • str

    The cleaned text.

extract_sprite_presets

extract_sprite_presets(text: str) -> list[tuple[str, str]]

Extract sprite presets from a string.

Parameters:

  • text

    (str) –

    The text to process.

Returns:

  • list[tuple[str, str]]

    A list of tuples containing the SPRITE_PRESET keyword and icon URL.

format_num

format_num(digits: int, calculation: float) -> str

Format a number to a string with a fixed number of digits after the decimal point.

Parameters:

  • digits

    (int) –

    Number of digits after the decimal point.

  • calculation

    (float) –

    Number to format.

Returns:

  • str

    The formatted number.

format_stat_values

format_stat_values(
    values: dict[str, float],
) -> dict[str, str]

Format the stat values to a human-readable format.

Percentage values will be rounded to 1 decimal, while others will be rounded to the nearest integer.

Parameters:

  • values

    (dict[str, float]) –

    A dictionary of fight prop ID and value.

Returns:

  • dict[str, str]

    A dictionary of formatted stat values.

get_ascension_from_level

get_ascension_from_level(
    level: int, ascended: bool, game: Game
) -> int

Get the ascension from the level and ascended status.

Parameters:

  • level

    (int) –

    The level.

  • ascended

    (bool) –

    Whether the entity is ascended.

  • game

    (Game) –

    The game.

Returns:

  • int

    The ascension level.

get_max_level_from_ascension

get_max_level_from_ascension(
    ascension: int, game: Game
) -> int

Get the max level from the ascension.

Parameters:

  • ascension

    (int) –

    The ascension level.

  • game

    (Game) –

    The game.

Returns:

  • int

    The max level.

get_skill_attributes

get_skill_attributes(
    descriptions: list[str], params: list[int | float]
) -> str

Get the skill attributes from the descriptions.

Parameters:

  • descriptions

    (list[str]) –

    The list of descriptions.

  • params

    (list[int | float]) –

    The list of parameters.

Returns:

  • str

    A string containing the skill attributes.

remove_ruby_tags

remove_ruby_tags(text: str) -> str

Remove ruby tags from a string.

Parameters:

  • text

    (str) –

    The text to process.

Returns:

  • str

    The text with ruby tags removed.

replace_device_params

replace_device_params(text: str) -> str

Replace device parameters in a string with the corresponding values.

replace_fight_prop_with_name

replace_fight_prop_with_name(
    values: dict[str, T], manual_weapon: dict[str, str]
) -> dict[str, T]

Replace the fight prop with the corresponding name.

Manual weapon example: https://gi.yatta.moe/api/v2/en/manualWeapon

Parameters:

  • values

    (dict[str, T]) –

    A dictionary of fight prop ID and value.

  • manual_weapon

    (dict[str, str]) –

    A dictionary from project ambr with fight prop ID and value.

Returns:

  • dict[str, T]

    A dictionary with fight props replaced by names.

replace_layout

replace_layout(text: str) -> str

Replace the layout in a string with the corresponding word.

Parameters:

  • text

    (str) –

    The text to format.

Returns:

  • str

    The formatted text.

replace_params

replace_params(
    text: str, param_list: list[float]
) -> list[str]

Replace parameters in a string with the corresponding values.

Parameters:

  • text

    (str) –

    The text to replace the parameters in.

  • param_list

    (list[float]) –

    The list of parameters to replace the values with.

Returns:

  • list[str]

    The list of strings with the replaced parameters.

replace_placeholders

replace_placeholders(
    text: str, param_list: list[float]
) -> str

Replace placeholders in the given text with values from the parameter list.

Parameters:

  • text

    (str) –

    The text containing placeholders to be replaced.

  • param_list

    (list[float]) –

    The list of parameter values.

Returns:

  • str

    The text with placeholders replaced by their corresponding values.