summaryrefslogtreecommitdiff
path: root/Types.py
diff options
context:
space:
mode:
authorue86388 <dmitrii.morozov@sbb.ch>2024-04-16 15:28:02 +0200
committerue86388 <dmitrii.morozov@sbb.ch>2024-04-16 15:28:02 +0200
commit3089066696ce90eb1a4c0b381e9fc414ec00db85 (patch)
treea4d4b400052b9abcc0b629cc4f4a06abd986759b /Types.py
parent27c484c4bbd8e2393c8f410df7cb6f8b7c6235f2 (diff)
User statistics
Diffstat (limited to 'Types.py')
-rw-r--r--Types.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/Types.py b/Types.py
new file mode 100644
index 0000000..fc2e034
--- /dev/null
+++ b/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
+
+ __fortniteUser: 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.__fortniteUser = user
+
+ return instance
+
+ async def fetch_stats(self) -> UserStats:
+ stats = await self.__fortniteUser.fetch_br_stats()
+ bp_level: float = await self.__fortniteUser.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