File size: 4,490 Bytes
ee60860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00559cf
ee60860
e52b8e1
00559cf
 
 
 
 
ee60860
e52b8e1
ee60860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d20627
 
 
 
 
 
 
 
 
 
 
ee60860
 
 
 
 
 
 
 
 
 
00559cf
f957322
9d20627
 
 
 
 
 
 
 
 
 
 
f957322
9d20627
 
 
 
 
 
e52b8e1
f957322
00559cf
 
 
 
 
 
 
 
 
 
 
e52b8e1
00559cf
 
 
 
 
e52b8e1
 
 
 
 
 
 
 
 
 
9d20627
e52b8e1
 
 
 
 
 
 
 
 
 
83dba3e
9d20627
83dba3e
 
 
 
 
 
 
9d20627
f957322
 
 
 
 
 
 
 
83dba3e
 
 
 
 
 
 
 
 
157e563
 
9d20627
f957322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157e563
 
 
 
 
9d20627
157e563
 
 
 
 
9d20627
157e563
 
 
 
 
 
 
 
 
 
 
9d20627
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
from pydantic import BaseModel
from typing import Dict, List, Union


class Image(BaseModel):
    url: str
    width: int
    height: int


class Role(BaseModel):
    id: str
    team: str
    aura: str
    name: str
    description: str
    image: Image
    icons: List[str] = None


class RoleIcon(BaseModel):
    id: str
    rarity: str
    image: Image
    roleId: str


def _getRoleObjects(roles: List[Dict[str, Union[str, Dict]]]):
    roleList = []
    for role in roles:
        try:
            entry = Role(**role)
            roleList.append(entry)
        except Exception as e:
            print(e)
            print(role)
    return roleList


class Emoji(BaseModel):
    id: str
    name: str
    rarity: str
    urlPreview: str
    urlAnimation: str
    event: str = None


class EmojiCollection(BaseModel):
    id: str
    emojiIds: List[str]
    promoImageUrl: str
    promoImagePrimaryColor: str
    iconUrl: str
    bonusLoadingScreenId: str
    bonusMinItemCount: int
    emojis: List[Emoji] = []


def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
    emojiList = []
    for emoji in emojis:
        try:
            entry = Emoji(**emoji)
            emojiList.append(entry)
        except Exception as e:
            print(e)
            print(emoji)
    return emojiList


def _getEmojiCollectionObjects(emojis: List[Dict[str, Union[str, Dict]]]):
    emojCollectioniList = []
    for emoji in emojis:
        try:
            entry = EmojiCollection(**emoji)
            emojCollectioniList.append(entry)
        except Exception as e:
            print(e)
            print(emoji)
    return emojCollectioniList


def _mapEmojiCollections(emojis, collections):
    for item in collections:
        emojiIds = item.emojiIds
        emojis = [emoji for emoji in emojis if emoji.id in emojiIds]
        item.emojis = emojis
    return collections


def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
    roleIconList = []
    for icon in icons:
        try:
            entry = RoleIcon(**icon)
            roleIconList.append(entry)
        except Exception as e:
            print(e)
            print(icon)
    return roleIconList


def _mapRoleRoleIcons(roles, icons):
    for role in roles:
        id = role.id
        iconList = [icon.image.url for icon in icons if icon.roleId == id]
        role.icons = iconList
    return roles


class LoadingScreen(BaseModel):
    id: str
    rarity: str
    image: Image
    imageWide: Image
    imagePrimaryColor: str


def _getScreenObjects(screens: List[Dict[str, Union[str, Dict]]]):
    screenList = []
    for screen in screens:
        try:
            entry = LoadingScreen(**screen)
            screenList.append(entry)
        except Exception as e:
            print(e)
            print(screen)
    return screenList


class AvatarItems(BaseModel):
    id: str
    imageUrl: str
    type: str
    rarity: str
    costInGold: int = 0


class AvatarItemSets(BaseModel):
    id: str
    promoImageUrl: str
    avatarItemIds: List[str]
    promoImagePrimaryColor: str = None
    ids: List[AvatarItems] = []


def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
    itemList = []
    for item in items:
        try:
            entry = AvatarItems(**item)
            itemList.append(entry)
        except Exception as e:
            print(e)
            print(item)
    return itemList


def _getAvatarItemSetObjects(items: List[Dict[str, Union[str, Dict]]]):
    itemSetList = []
    for item in items:
        try:
            entry = AvatarItemSets(**item)
            itemSetList.append(entry)
        except Exception as e:
            print(e)
            print(item)
    return itemSetList

def _mapItemItemSets(sets, items):
    for setItem in sets:
        avatarIds = setItem.avatarItemIds
        ids = [item.imageUrl for item in items if item.id in avatarIds]
        setItem.ids = ids
    return sets

class ProfileIcons(BaseModel):
    id: str
    name: str
    rarity: str


def getIconName(name: str):
    parts = name.split(":")
    icon = parts[1]
    return icon


def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
    profileIconList = []
    for icon in profile_icons:
        try:
            entry = ProfileIcons(**icon)
            entry.name = getIconName(entry.name)

            profileIconList.append(entry)
        except Exception as e:
            print(e)
            print(icon)
    return profileIconList