From cfa79cbbaf42a8f74a2cd4bca4d1d495b4d597f1 Mon Sep 17 00:00:00 2001 From: Dmitrii Morozov Date: Tue, 7 May 2024 16:50:38 +0200 Subject: Python code style --- app_types.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app_types.py (limited to 'app_types.py') diff --git a/app_types.py b/app_types.py new file mode 100644 index 0000000..699928a --- /dev/null +++ b/app_types.py @@ -0,0 +1,50 @@ +import fortnitepy + +class UserStats: + user_id: str + user_display_name: str + level: int + matches_played: int + kills: int + wins: int + +class User: + + id: str + display_name: str + + __fortnite_user: fortnitepy.user.UserBase + + def from_fortnite_friend(user: fortnitepy.user.UserBase): + + if user is None: + return None + + instance = User() + + instance.id = user.id + instance.display_name = user.display_name + instance.__fortnite_user = user + + return instance + + async def fetch_stats(self) -> UserStats: + stats = await self.__fortnite_user.fetch_br_stats() + bp_level: float = await self.__fortnite_user.fetch_battlepass_level(season=29) # TODO + combined_stats = stats.get_combined_stats() + device_stats = {} + if 'keyboardmouse' in combined_stats: + device_stats = combined_stats['keyboardmouse'] + else: + device_stats = combined_stats['gamepad'] + + stats = UserStats() + + stats.user_id = self.id + stats.user_display_name = self.display_name + stats.level = int(bp_level//1) + stats.matches_played = device_stats['matchesplayed'] + stats.kills = device_stats['kills'] + stats.wins = device_stats['wins'] + + return stats \ No newline at end of file -- cgit v1.2.3