-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_player.py
More file actions
76 lines (65 loc) · 2.66 KB
/
Copy pathget_player.py
File metadata and controls
76 lines (65 loc) · 2.66 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
get_player.py
Script to illustrate the basic usage of the async swgoh_comlink wrapper library
"""
import asyncio
# import the SwgohComlinkAsync class from the swgoh_comlink module
from swgoh_comlink import SwgohComlinkAsync
async def main():
# create an instance of a SwgohComlinkAsync object
async with SwgohComlinkAsync() as comlink:
"""
# Call the get_player() method of the SwgohComlinkAsync instance for a specific player ID or allyCode.
# We use allyCode in this example.
The result is a dictionary with the following top level keys:
{
'allyCode': '314927874',
'datacron': [...],
'guildBannerColor': 'bright_blue_dark_blue',
'guildBannerLogo': 'guild_icon_flame',
'guildId': '8RhppbbqR_ShmjY5S6ZtQg',
'guildLogoBackground': '',
'guildName': 'sL Dead Forest Guards',
'guildTypeId': 'NORMAL',
'lastActivityTime': '1684104401000',
'level': 85,
'lifetimeSeasonScore': '731008',
'localTimeZoneOffsetMinutes': 420,
'name': 'Mar Trepodi',
'playerId': 'cRdX7yGvS-eKfyDxAAgaYw',
'playerRating': {...},
'profileStat': [...],
'pvpProfile': [...],
'rosterUnit': [...],
'seasonStatus': [...],
'selectedPlayerPortrait': {...},
'selectedPlayerTitle': {...},
'unlockedPlayerPortrait': [...],
'unlockedPlayerTitle': [...]
}
"""
player_profile_data = await comlink.get_player(allycode=314927874)
# We can extract a list of the characters in the player's roster
player_roster = player_profile_data['rosterUnit']
"""
# Each unit in a player's roster is a dictionary with entries for all attributes including skills,
# equipped mods and relics
>>> pprint.pprint(player['rosterUnit'][0], depth=1)
{
'currentLevel': 85,
'currentRarity': 7,
'currentTier': 13,
'currentXp': 883025,
'definitionId': 'MAGMATROOPER:SEVEN_STAR',
'equipment': [],
'equippedStatMod': [...],
'equippedStatModOld': [],
'id': 'xCNyaUFiR8OY3u5Qc-dC8Q',
'promotionRecipeReference': '',
'purchasedAbilityId': [],
'relic': {...},
'skill': [...],
'unitStat': None
}
"""
asyncio.run(main())