Skip to content

Commit

Permalink
feat: Add support for Natlan reputation data in exploration stats
Browse files Browse the repository at this point in the history
  • Loading branch information
KT-Yeh committed Sep 16, 2024
1 parent 820bb06 commit 7a7cb43
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions genshin/models/genshin/chronicle/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from . import abyss, activities, characters

__all__ = [
"AreaExploration",
"BossKill",
"Exploration",
"FullGenshinUserStats",
"GenshinUserStats",
Expand All @@ -25,6 +27,8 @@
"Stats",
"Teapot",
"TeapotRealm",
"NatlanReputation",
"NatlanTribe",
]


Expand All @@ -43,6 +47,7 @@ class Stats(APIModel):
dendroculi: int = Aliased("dendroculus_number", mi18n="bbs/dendro_culus")
electroculi: int = Aliased("electroculus_number", mi18n="bbs/electroculus_god")
hydroculi: int = Aliased("hydroculus_number", mi18n="bbs/hydro_god")
pyroculi: int = Aliased("pyroculus_number", mi18n="bbs/pyro_gid")
common_chests: int = Aliased("common_chest_number", mi18n="bbs/general_treasure_box_count")
exquisite_chests: int = Aliased("exquisite_chest_number", mi18n="bbs/delicacy_treasure_box_count")
precious_chests: int = Aliased("precious_chest_number", mi18n="bbs/rarity_treasure_box_count")
Expand All @@ -52,10 +57,10 @@ class Stats(APIModel):
unlocked_domains: int = Aliased("domain_number", mi18n="bbs/unlock_secret_area")
# fmt: on

def as_dict(self, lang: typing.Optional[str] = None) -> typing.Mapping[str, typing.Any]:
def as_dict(self, lang: str = "en-us") -> typing.Mapping[str, typing.Any]:
"""Turn fields into properly named ones."""
return {
self._get_mi18n(field, lang or self.lang): getattr(self, field.name)
self._get_mi18n(field, lang): getattr(self, field.name)
for field in self.__fields__.values()
if field.name != "lang"
}
Expand All @@ -69,6 +74,41 @@ class Offering(APIModel):
icon: str = ""


class BossKill(APIModel):
"""Boss kills in exploration"""

name: str
kills: int = Aliased("kill_num")


class AreaExploration(APIModel):
"""Area exploration data."""

name: str
raw_explored: int = Aliased("exploration_percentage")

@property
def explored(self) -> float:
"""The percentage explored. (Note: This can go above 100%)"""
return self.raw_explored / 10


class NatlanTribe(APIModel):
"""Natlan tribe data."""

icon: str
image: str
name: str
id: int
level: int


class NatlanReputation(APIModel):
"""Natlan reputation data."""

tribes: typing.Sequence[NatlanTribe] = Aliased("tribal_list")


class Exploration(APIModel):
"""Exploration data."""

Expand All @@ -88,6 +128,9 @@ class Exploration(APIModel):
map_url: str

offerings: typing.Sequence[Offering]
boss_list: typing.Sequence[BossKill]
area_exploration_list: typing.Sequence[AreaExploration]
natlan_reputation: typing.Optional[NatlanReputation] = Aliased("natan_reputation", default=None)

@property
def explored(self) -> float:
Expand Down

0 comments on commit 7a7cb43

Please sign in to comment.