Skip to content

Commit

Permalink
🐛 Fix missed proudSkillExtraLevelMap from simnet to enka
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Aug 27, 2024
1 parent 71267bb commit 05abee3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
33 changes: 30 additions & 3 deletions modules/playercards/to_enka.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,39 @@ def get_skill_depot_id(data: "GenshinDetailCharacter") -> int:
return skill_id_pre + skill_id


def get_skill_level_map(data: "GenshinDetailCharacter") -> Dict:
return {str(skill.id): skill.level for skill in data.skills if skill.skill_type == 1}
def get_skill_level_map(data: "GenshinDetailCharacter", proud_skill_extra_level_map: Dict[str, int]) -> Dict:
_data = {}
for skill in data.skills:
if skill.skill_type != 1:
continue

_skill = Assets.skills(skill.id)
if not _skill:
continue

level = skill.level
if proud_skill_extra_level_map:
boost_level = proud_skill_extra_level_map.get(str(_skill.pround_map), None)
if boost_level is not None:
level -= boost_level
_data[str(skill.id)] = level
return _data


def get_talent_id_list(data: "GenshinDetailCharacter") -> List[int]:
return [constellation.id for constellation in data.constellations if constellation.activated]


def get_proud_skill_extra_level_map(avatar_id: int, talent_count: int) -> Dict[str, int]:
level_map = Assets.DATA["talents"].get(str(avatar_id), {})
data = {}
for k, v in level_map.items():
if talent_count >= int(k):
if talent_data := level_map.get(k):
data[str(talent_data["proud_skill_group_id"])] = talent_data["extra_level"]
return data


def from_simnet_to_enka_single(index: int, data: "GenshinDetailCharacters") -> Dict:
character = data.characters[index]
avatar_id = character.base.id
Expand All @@ -195,8 +220,9 @@ def from_simnet_to_enka_single(index: int, data: "GenshinDetailCharacters") -> D
inherent_proud_skill_list = get_inherent_proud_skill_list(character)
prop_map = get_prop_map(character)
skill_depot_id = get_skill_depot_id(character)
skill_level_map = get_skill_level_map(character)
talent_id_list = get_talent_id_list(character)
proud_skill_extra_level_map = get_proud_skill_extra_level_map(avatar_id, len(talent_id_list))
skill_level_map = get_skill_level_map(character, proud_skill_extra_level_map)
return {
"avatarId": avatar_id,
"equipList": equip_list,
Expand All @@ -207,6 +233,7 @@ def from_simnet_to_enka_single(index: int, data: "GenshinDetailCharacters") -> D
"inherentProudSkillList": inherent_proud_skill_list,
"fightPropMap": fight_prop_map,
"skillLevelMap": skill_level_map,
"proudSkillExtraLevelMap": proud_skill_extra_level_map,
}


Expand Down
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ click==8.1.7
colorama==0.4.6; sys_platform == "win32" or platform_system == "Windows"
colorlog==6.8.2
cryptography==43.0.0
enkanetwork-py @ git+https://github.com/PaiGramTeam/EnkaNetwork.py@77265cfdee0c0767d08791f28b54d9c105868a93
enkanetwork-py @ git+https://github.com/PaiGramTeam/EnkaNetwork.py@0924cbce3b8b61cee1db33d7bc7a89f34572a048
et-xmlfile==1.1.0
exceptiongroup==1.2.2; python_version < "3.11"
fakeredis==2.24.1
Expand All @@ -42,7 +42,7 @@ greenlet==3.0.3
h11==0.14.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
httpx==0.27.2
idna==3.7
importlib-metadata==8.4.0; python_version < "3.9"
importlib-resources==6.4.4; python_version < "3.9"
Expand Down

0 comments on commit 05abee3

Please sign in to comment.