Abhinav commited on
Commit
f957322
·
unverified ·
1 Parent(s): 9d20627

feat: Avatar Items

Browse files
pages/Avatar_Items.py CHANGED
@@ -1,11 +1,12 @@
1
  import streamlit as st
2
  from utils.wolvesville import Wolvesville
3
- from utils.models import AvatarItems
4
  from typing import List
5
 
6
  api = Wolvesville()
7
 
8
  items: List[AvatarItems] = api.getItems()
 
9
 
10
  st.title("Avatar Items")
11
 
@@ -22,3 +23,20 @@ for item in items[:5]:
22
  st.button(f"{item.costInGold} 🪙", key=item.id)
23
 
24
  st.divider()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from utils.wolvesville import Wolvesville
3
+ from utils.models import AvatarItems, AvatarItemSets
4
  from typing import List
5
 
6
  api = Wolvesville()
7
 
8
  items: List[AvatarItems] = api.getItems()
9
+ itemSets : List[AvatarItemSets] = api.getItemAsSets()
10
 
11
  st.title("Avatar Items")
12
 
 
23
  st.button(f"{item.costInGold} 🪙", key=item.id)
24
 
25
  st.divider()
26
+
27
+ st.title("Item Collections")
28
+ for item in itemSets[:5]:
29
+ st.markdown(
30
+ f'<img src="{item.promoImageUrl}" style="height: 75%; width:75%;"/>',
31
+ unsafe_allow_html=True,
32
+ )
33
+
34
+ if item.ids != []:
35
+ with st.expander("See item sets"):
36
+ for id in item.ids:
37
+ st.markdown(
38
+ f'<img src="{id}" style="height: 25%; width:25%;"/>',
39
+ unsafe_allow_html=True,
40
+ )
41
+
42
+ st.divider()
pages/Emojis.py CHANGED
@@ -18,7 +18,7 @@ for emoji in emojis[:5]:
18
  unsafe_allow_html=True,
19
  )
20
  st.markdown(f"Event: {emoji.event.title() if emoji.event else 'None'}")
21
-
22
  st.header("Emoji Collections")
23
 
24
  for item in collections[:5]:
@@ -40,7 +40,7 @@ for item in collections[:5]:
40
  f'<img src="{emoji.urlPreview}" style="height: 100px; width:100px;"/>',
41
  unsafe_allow_html=True,
42
  )
43
- eventName = emoji.event.title() if emoji.event else 'None'
44
  eventName = " ".join(eventName.split("_"))
45
  st.markdown(f"Event: {eventName}")
46
  st.divider()
 
18
  unsafe_allow_html=True,
19
  )
20
  st.markdown(f"Event: {emoji.event.title() if emoji.event else 'None'}")
21
+
22
  st.header("Emoji Collections")
23
 
24
  for item in collections[:5]:
 
40
  f'<img src="{emoji.urlPreview}" style="height: 100px; width:100px;"/>',
41
  unsafe_allow_html=True,
42
  )
43
+ eventName = emoji.event.title() if emoji.event else "None"
44
  eventName = " ".join(eventName.split("_"))
45
  st.markdown(f"Event: {eventName}")
46
  st.divider()
utils/models.py CHANGED
@@ -68,6 +68,7 @@ def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
68
  print(emoji)
69
  return emojiList
70
 
 
71
  def _getEmojiCollectionObjects(emojis: List[Dict[str, Union[str, Dict]]]):
72
  emojCollectioniList = []
73
  for emoji in emojis:
@@ -79,6 +80,7 @@ def _getEmojiCollectionObjects(emojis: List[Dict[str, Union[str, Dict]]]):
79
  print(emoji)
80
  return emojCollectioniList
81
 
 
82
  def _mapEmojiCollections(emojis, collections):
83
  for item in collections:
84
  emojiIds = item.emojiIds
@@ -86,6 +88,7 @@ def _mapEmojiCollections(emojis, collections):
86
  item.emojis = emojis
87
  return collections
88
 
 
89
  def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
90
  roleIconList = []
91
  for icon in icons:
@@ -134,6 +137,14 @@ class AvatarItems(BaseModel):
134
  costInGold: int = 0
135
 
136
 
 
 
 
 
 
 
 
 
137
  def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
138
  itemList = []
139
  for item in items:
@@ -146,6 +157,24 @@ def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
146
  return itemList
147
 
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  class ProfileIcons(BaseModel):
150
  id: str
151
  name: str
 
68
  print(emoji)
69
  return emojiList
70
 
71
+
72
  def _getEmojiCollectionObjects(emojis: List[Dict[str, Union[str, Dict]]]):
73
  emojCollectioniList = []
74
  for emoji in emojis:
 
80
  print(emoji)
81
  return emojCollectioniList
82
 
83
+
84
  def _mapEmojiCollections(emojis, collections):
85
  for item in collections:
86
  emojiIds = item.emojiIds
 
88
  item.emojis = emojis
89
  return collections
90
 
91
+
92
  def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
93
  roleIconList = []
94
  for icon in icons:
 
137
  costInGold: int = 0
138
 
139
 
140
+ class AvatarItemSets(BaseModel):
141
+ id: str
142
+ promoImageUrl: str
143
+ avatarItemIds: List[str]
144
+ promoImagePrimaryColor: str = None
145
+ ids: List[AvatarItems] = []
146
+
147
+
148
  def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
149
  itemList = []
150
  for item in items:
 
157
  return itemList
158
 
159
 
160
+ def _getAvatarItemSetObjects(items: List[Dict[str, Union[str, Dict]]]):
161
+ itemSetList = []
162
+ for item in items:
163
+ try:
164
+ entry = AvatarItemSets(**item)
165
+ itemSetList.append(entry)
166
+ except Exception as e:
167
+ print(e)
168
+ print(item)
169
+ return itemSetList
170
+
171
+ def _mapItemItemSets(sets, items):
172
+ for setItem in sets:
173
+ avatarIds = setItem.avatarItemIds
174
+ ids = [item.imageUrl for item in items if item.id in avatarIds]
175
+ setItem.ids = ids
176
+ return sets
177
+
178
  class ProfileIcons(BaseModel):
179
  id: str
180
  name: str
utils/wolvesville.py CHANGED
@@ -7,7 +7,9 @@ from utils.models import (
7
  _getAvatarObjects,
8
  _getProfileIconObjects,
9
  _getEmojiCollectionObjects,
10
- _mapEmojiCollections
 
 
11
  )
12
  from dotenv import load_dotenv
13
  from os import getenv
@@ -46,9 +48,11 @@ class Wolvesville:
46
  emojis = requests.get(f"{self.url}/items/emojis", headers=self.headers).json()
47
  resp = _getEmojiObjects(emojis=emojis)
48
  return resp
49
-
50
  def getEmojiCollections(self):
51
- emojis = requests.get(f"{self.url}/items/emojiCollections", headers=self.headers).json()
 
 
52
  resp = _getEmojiCollectionObjects(emojis=emojis)
53
  return resp
54
 
@@ -58,6 +62,7 @@ class Wolvesville:
58
  mapping = _mapEmojiCollections(emojis=emojis, collections=collections)
59
  return mapping
60
 
 
61
  def getScreens(self):
62
  screens = requests.get(
63
  f"{self.url}/items/loadingScreens", headers=self.headers
@@ -66,12 +71,25 @@ class Wolvesville:
66
  return resp
67
 
68
  def getItems(self):
69
- screens = requests.get(
70
  f"{self.url}/items/avatarItems", headers=self.headers
71
  ).json()
72
- resp = _getAvatarObjects(items=screens)
73
  return resp
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  def getProfileIcons(self):
76
  icons = requests.get(
77
  f"{self.url}/items/profileIcons", headers=self.headers
 
7
  _getAvatarObjects,
8
  _getProfileIconObjects,
9
  _getEmojiCollectionObjects,
10
+ _mapEmojiCollections,
11
+ _getAvatarItemSetObjects,
12
+ _mapItemItemSets
13
  )
14
  from dotenv import load_dotenv
15
  from os import getenv
 
48
  emojis = requests.get(f"{self.url}/items/emojis", headers=self.headers).json()
49
  resp = _getEmojiObjects(emojis=emojis)
50
  return resp
51
+
52
  def getEmojiCollections(self):
53
+ emojis = requests.get(
54
+ f"{self.url}/items/emojiCollections", headers=self.headers
55
+ ).json()
56
  resp = _getEmojiCollectionObjects(emojis=emojis)
57
  return resp
58
 
 
62
  mapping = _mapEmojiCollections(emojis=emojis, collections=collections)
63
  return mapping
64
 
65
+
66
  def getScreens(self):
67
  screens = requests.get(
68
  f"{self.url}/items/loadingScreens", headers=self.headers
 
71
  return resp
72
 
73
  def getItems(self):
74
+ items = requests.get(
75
  f"{self.url}/items/avatarItems", headers=self.headers
76
  ).json()
77
+ resp = _getAvatarObjects(items=items)
78
  return resp
79
 
80
+ def getItemSets(self):
81
+ itemSets = requests.get(
82
+ f"{self.url}/items/avatarItemSets", headers=self.headers
83
+ ).json()
84
+ resp = _getAvatarItemSetObjects(items=itemSets)
85
+ return resp
86
+
87
+ def getItemAsSets(self):
88
+ items = self.getItems()
89
+ sets = self.getItemSets()
90
+ mapping = _mapItemItemSets(sets=sets, items=items)
91
+ return mapping
92
+
93
  def getProfileIcons(self):
94
  icons = requests.get(
95
  f"{self.url}/items/profileIcons", headers=self.headers