Skip to content

Commit

Permalink
docs: Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Feb 2, 2024
1 parent 6b8185c commit ce39b98
Showing 1 changed file with 41 additions and 18 deletions.
59 changes: 41 additions & 18 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import asyncio

import enka
from enka.enums import FightProp
from enka.enums import FightPropType

FIGHT_PROPS_TO_SHOW = (
FightPropType.FIGHT_PROP_MAX_HP,
FightPropType.FIGHT_PROP_CUR_ATTACK,
FightPropType.FIGHT_PROP_CUR_DEFENSE,
FightPropType.FIGHT_PROP_ELEMENT_MASTERY,
FightPropType.FIGHT_PROP_CRITICAL,
FightPropType.FIGHT_PROP_CRITICAL_HURT,
FightPropType.FIGHT_PROP_CHARGE_EFFICIENCY,
)


async def main() -> None:
Expand All @@ -19,25 +29,38 @@ async def main() -> None:
print("Namecard:", response.player.namecard.full)

for character in response.characters:
print("\n==================\n")
print(character.name)
print("Level:", character.level)
print("Element:", character.element.name)
print("Constellation:", len(character.constellations))
print("Weapon:", character.weapon.name)
print("Weapon level:", character.weapon.level)
print("Weapon refinement:", character.weapon.refinement)
print("Side icon:", character.icon.side)
print("HP:", round(character.stats[FightProp.FIGHT_PROP_CUR_HP].value))
print("Attack:", round(character.stats[FightProp.FIGHT_PROP_CUR_ATTACK].value))
print(
"Defense:",
round(character.stats[FightProp.FIGHT_PROP_CUR_DEFENSE].value),
)
print("\n===============================\n")
print(
"Energy recharge:",
f"{round(character.stats[FightProp.FIGHT_PROP_CHARGE_EFFICIENCY].value, 1)}%",
f"Lv. {character.level}/{character.max_level} {character.name} (C{len(character.constellations)})"
)
print(f"Rarity: {character.rarity} ★")
print("Element:", character.element.name.title())
print("Side icon:", character.icon.side)
print(f"Talent levels: {'/'.join(str(talent.level) for talent in character.talents)}")

weapon = character.weapon
print("\nWeapon:")
print(f"Lv. {weapon.level}/{weapon.max_level} {weapon.name} (R{weapon.refinement})")
print(f"Rarity: {weapon.rarity} ★")
for stat in weapon.stats:
print(stat.name, stat.formatted_value)

print("\nStats:")
for stat_type, stat in character.stats.items():
if stat_type in FIGHT_PROPS_TO_SHOW:
print(stat.name, stat.formatted_value)
dmg_bonus = character.highest_dmg_bonus_stat
print(dmg_bonus.name, dmg_bonus.formatted_value)

print("\nArtifacts:")
for artifact in character.artifacts:
main_stat = artifact.main_stat
print(
f"Lv. {artifact.level} {artifact.name}: {main_stat.name} {main_stat.formatted_value}"
)
for substat in artifact.sub_stats:
print(f"- {substat.name} {substat.formatted_value}")
print("")


asyncio.run(main())

0 comments on commit ce39b98

Please sign in to comment.