Skip to content

API Reference

utils

Functions:

  • calculate_upgrade_stat_values –

    Calculates the stat values for a character or weapon at a specific level and ascension status.

  • format_layout –

    Extracts and replaces layout placeholders like {LAYOUT_MOBILE#Character Skill}.

  • format_num –

    Formats a number to a specified number of decimal places.

  • format_stat_values –

    Formats calculated stat values into strings, adding '%' for percentage stats.

  • get_params –

    Replaces parameter placeholders in text with formatted values from a list.

  • get_skill_attributes –

    Generates a formatted string of skill attributes from descriptions and parameters.

  • remove_html_tags –

    Removes HTML tags, sprite presets, and link tags from a string.

  • replace_fight_prop_with_name –

    Replaces fight property IDs (e.g., FIGHT_PROP_HP) with their human-readable names.

  • replace_placeholders –

    Replaces placeholders in a string with values from a dictionary.

  • replace_pronouns –

    Replaces gendered pronouns in the format {F#She}/{M#He} with She/He.

calculate_upgrade_stat_values

Calculates the stat values for a character or weapon at a specific level and ascension status.

Parameters:

Returns:

  • dict[str, float] –

    A dictionary mapping fight property IDs to their calculated values.

format_layout

format_layout(text: str) -> str

Extracts and replaces layout placeholders like {LAYOUT_MOBILE#Character Skill}.

Parameters:

  • text

    (str) –

    The input string potentially containing layout placeholders.

Returns:

  • str –

    The string with layout placeholders replaced by their content.

format_num

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

Formats a number to a specified number of decimal places.

Parameters:

  • digits

    (int) –

    The number of decimal places.

  • calculation

    (int | float) –

    The number to format.

Returns:

  • str –

    The formatted number as a string.

format_stat_values

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

Formats calculated stat values into strings, adding '%' for percentage stats.

Parameters:

  • stat_values

    (dict[str, float]) –

    A dictionary mapping fight property IDs to their numerical values.

Returns:

  • dict[str, str] –

    A dictionary mapping fight property IDs to their formatted string values.

get_params

get_params(text: str, param_list: list[int | float]) -> list[str]

Replaces parameter placeholders in text with formatted values from a list.

Placeholders are in the format {param:}, e.g., {param1:F1P}. Formats include: F1P, F2P: Float multiplied by 100, formatted to 1 or 2 decimal places with '%'. F1, F2: Float formatted to 1 or 2 decimal places. P: Float multiplied by 100, formatted to 0 decimal places with '%'. I: Integer.

Parameters:

  • text

    (str) –

    The input string containing parameter placeholders.

  • param_list

    (list[int | float]) –

    A list of numerical parameter values.

Returns:

  • list[str] –

    A list of strings, typically split by '|', after parameter replacement and formatting.

get_skill_attributes

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

Generates a formatted string of skill attributes from descriptions and parameters.

Each description is processed by get_params and expected to return a key-value pair separated by '|'.

Parameters:

  • descriptions

    (list[str]) –

    A list of strings containing parameter placeholders, often separated by '|'.

  • params

    (list[int | float]) –

    A list of numerical parameter values for substitution.

Returns:

  • str –

    A newline-separated string of "key: value" pairs for the skill attributes.

remove_html_tags

remove_html_tags(text: str) -> str

Removes HTML tags, sprite presets, and link tags from a string.

Parameters:

  • text

    (str) –

    The input string containing HTML tags.

Returns:

  • str –

    The string with HTML tags, sprite presets, and link tags removed.

replace_fight_prop_with_name

replace_fight_prop_with_name(stat_values: dict[str, Any], manual_weapon: dict[str, str]) -> dict[str, Any]

Replaces fight property IDs (e.g., FIGHT_PROP_HP) with their human-readable names.

Parameters:

  • stat_values

    (dict[str, Any]) –

    A dictionary mapping fight property IDs to their values.

  • manual_weapon

    (dict[str, str]) –

    A dictionary mapping fight property IDs to their names.

Returns:

  • dict[str, Any] –

    A dictionary mapping fight property names to their values.

replace_placeholders

replace_placeholders(string: str, params: dict[str, Any]) -> str

Replaces placeholders in a string with values from a dictionary.

Placeholders are in the format $[key].

Parameters:

  • string

    (str) –

    The input string containing placeholders.

  • params

    (dict[str, Any]) –

    A dictionary mapping placeholder keys to their values.

Returns:

  • str –

    The string with placeholders replaced and sprite presets removed.

replace_pronouns

replace_pronouns(text: str) -> str

Replaces gendered pronouns in the format {F#She}/{M#He} with She/He.

Parameters:

  • text

    (str) –

    The input string containing gendered pronouns.

Returns:

  • str –

    The string with pronouns replaced.