Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed enka_parser wrongly taking some percentages as decimals. #8

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions python_genshin_artifact/enka/enka_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from python_genshin_artifact.enka.artifacts import artifacts_name_map, equip_type_map
from python_genshin_artifact.enka.assets import Assets
from python_genshin_artifact.enka.characters import characters_map
from python_genshin_artifact.enka.fight import fight_map
from python_genshin_artifact.enka.fight import fight_map, toFloat
from python_genshin_artifact.enka.weapon import weapon_name_map
from python_genshin_artifact.models.artifact import ArtifactInfo
from python_genshin_artifact.models.characterInfo import CharacterInfo
Expand Down Expand Up @@ -82,26 +82,12 @@ def de_equip_list(equip_list: list[dict]) -> Tuple[WeaponInfo, List[ArtifactInfo
_reliquary_main_stat = _flat["reliquaryMainstat"]
_main_prop_id = _reliquary_main_stat["mainPropId"]
stat_name = fight_map[_main_prop_id]
stat_value = _reliquary_main_stat["statValue"]
if "_PERCENT" in _main_prop_id:
stat_value /= 100
elif "FIGHT_PROP_CRITICAL" in _main_prop_id:
stat_value /= 100
elif "FIGHT_PROP_CRITICAL_HURT" in _main_prop_id:
stat_value /= 100
elif "_ADD_HURT" in _main_prop_id:
stat_value /= 100
stat_value = toFloat(_main_prop_id, _reliquary_main_stat["statValue"])
_main_stat = (stat_name, stat_value)
for _reliquary_sub_stats in _flat["reliquarySubstats"]:
_append_prop_id = _reliquary_sub_stats["appendPropId"]
stat_name = fight_map[_append_prop_id]
stat_value = _reliquary_sub_stats["statValue"]
if "_PERCENT" in _append_prop_id:
stat_value /= 100
elif "FIGHT_PROP_CRITICAL" in _append_prop_id:
stat_value /= 100
elif "FIGHT_PROP_CRITICAL_HURT" in _append_prop_id:
stat_value /= 100
stat_value = toFloat(_append_prop_id, _reliquary_sub_stats["statValue"])
_sub_stats = (stat_name, stat_value)
sub_stats.append(_sub_stats)
slot = equip_type_map[_flat["equipType"]]
Expand Down
13 changes: 12 additions & 1 deletion python_genshin_artifact/enka/fight.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, List

fight_map: Dict[str, str] = {
"FIGHT_PROP_ATTACK": "ATKFixed",
Expand All @@ -21,3 +21,14 @@
"FIGHT_PROP_ROCK_ADD_HURT": "GeoBonus",
"FIGHT_PROP_GRASS_ADD_HURT": "DendroBonus",
}

fixed: List[str] = {
"FIGHT_PROP_ATTACK",
"FIGHT_PROP_DEFENSE",
"FIGHT_PROP_HP",
"FIGHT_PROP_ELEMENT_MASTERY",
}


def toFloat(prop_id: str, pc: float) -> float:
return pc if prop_id in fixed else (pc / 100)
Loading