# Path: scripts/helpers.py
# def try_divide(numerator: Union[int, float], denominator: Union[int, float]):
#     """
#     Try to divide two numbers.
#     :param numerator: the numerator.
#     :param denominator: the denominator.
#     :return: the result of the division if denominator is not zero else 0.
#     """
#     return numerator / denominator if denominator else 0


from typing import Optional
from discord import Embed
from scripts.helpers import try_divide
    damage_dealt = all_time_stats['damage_dealt']
    max_damage_dealt = all_time_stats['max_damage_dealt']
    planes_killed = all_time_stats['planes_killed']
    wins = all_time_stats['wins']
    xp = all_time_stats['xp']
    survived_battles = all_time_stats['survived_battles']
    ships_spotted = all_time_stats['ships_spotted']
    warships_killed = all_time_stats['frags']
    deaths = battles - survived_battles
    # max_xp = str(all_time_stats['max_xp'])
    # max_planes_killed = str(all_time_stats['max_planes_killed'])

    kda = f'{(warships_killed / deaths):.2f}' if deaths else '\u221E'
    a(name='All Time Stats', value=f'{battles:,} Battles', inline=False)
    a(name='WTR', value=f'{wtr:,}')
    a(name='Win Rate', value=f'{((wins / battles) * 100):.2f}%')
    a(name='Max Damage Dealt', value=f'{max_damage_dealt:,}')
    a(name='Average Damage', value=f'{(damage_dealt // battles):,}')
    a(name='Average Experience', value=f'{(xp//battles):,}')
    a(name='Average Kills', value=f'{(warships_killed / battles):.2f}')
    a(
        name='Average Plane Kills',
        value=f'{(planes_killed / battles):.2f}'
    )
    a(
        name='Average Ships Spotted',
        value=f'{(ships_spotted / battles):.2f}'
    )
    a(
        name='Main Battery Hit Rate',

# Path: scripts/helpers.py
# def try_divide(numerator: Union[int, float], denominator: Union[int, float]):
#     """
#     Try to divide two numbers.
#     :param numerator: the numerator.
#     :param denominator: the denominator.
#     :return: the result of the division if denominator is not zero else 0.
#     """
#     return numerator / denominator if denominator else 0


# Path: world_of_warships/embed_builder.py
from typing import Optional
from discord import Embed
from scripts.helpers import try_divide

    damage_dealt = all_time_stats['damage_dealt']
    max_damage_dealt = all_time_stats['max_damage_dealt']
    planes_killed = all_time_stats['planes_killed']
    wins = all_time_stats['wins']
    xp = all_time_stats['xp']
    survived_battles = all_time_stats['survived_battles']
    ships_spotted = all_time_stats['ships_spotted']
    warships_killed = all_time_stats['frags']
    deaths = battles - survived_battles
    # max_xp = str(all_time_stats['max_xp'])
    # max_planes_killed = str(all_time_stats['max_planes_killed'])

    kda = f'{(warships_killed / deaths):.2f}' if deaths else '\u221E'
    a(name='All Time Stats', value=f'{battles:,} Battles', inline=False)
    a(name='WTR', value=f'{wtr:,}')
    a(name='Win Rate', value=f'{((wins / battles) * 100):.2f}%')
    a(name='Max Damage Dealt', value=f'{max_damage_dealt:,}')
    a(name='Average Damage', value=f'{(damage_dealt // battles):,}')
    a(name='Average Experience', value=f'{(xp//battles):,}')
    a(name='Average Kills', value=f'{(warships_killed / battles):.2f}')
    a(
        name='Average Plane Kills',
        value=f'{(planes_killed / battles):.2f}'
    )
    a(
        name='Average Ships Spotted',
        value=f'{(ships_spotted / battles):.2f}'
    )
    a(
        name='Main Battery Hit Rate',

        value=f'{(try_divide(main_hits, main_shots) * 100):.2f}%'