blob: 699928afc4350b90a225baaca0acae6b5c53c7b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
|