Skip to content

Commit

Permalink
refactor: Refactor percentage stat conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Feb 2, 2024
1 parent 8654da8 commit d83bd32
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions enka/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ def _post_process_character(self, character: "Character") -> "Character":
weapon.name = self._assets.text_map[weapon.name]
for stat in weapon.stats:
stat.name = self._assets.text_map[stat.type.value]
if stat.type.name in PERCENT_STAT_TYPES:
stat.value *= 100
stat.value *= 100 if stat.type.name in PERCENT_STAT_TYPES else 1

# artifacts
for artifact in character.artifacts:
Expand All @@ -158,14 +157,12 @@ def _post_process_character(self, character: "Character") -> "Character":
artifact.main_stat.name = self._assets.text_map[artifact.main_stat.type.value]
for stat in artifact.sub_stats:
stat.name = self._assets.text_map[stat.type.value]
if stat.type.name in PERCENT_STAT_TYPES:
stat.value *= 100
stat.value *= 100 if stat.type.name in PERCENT_STAT_TYPES else 1

# stats
for stat_type, stat in character.stats.items():
stat.name = self._assets.text_map.get(stat_type.name)
if stat_type.name in PERCENT_STAT_TYPES:
stat.value *= 100
stat.value *= 100 if stat_type.name in PERCENT_STAT_TYPES else 1

# constellations
for constellation in character.constellations:
Expand Down

0 comments on commit d83bd32

Please sign in to comment.