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

feat: Add support for emojis and grouped collections

Browse files
pages/Avatar_Items.py CHANGED
@@ -19,6 +19,6 @@ for item in items[:5]:
19
  st.subheader(itemType)
20
  rarity = item.rarity.title()
21
  st.markdown(rarity)
22
- st.markdown(f"{item.costInGold} 🪙")
23
 
24
  st.divider()
 
19
  st.subheader(itemType)
20
  rarity = item.rarity.title()
21
  st.markdown(rarity)
22
+ st.button(f"{item.costInGold} 🪙", key=item.id)
23
 
24
  st.divider()
pages/Emojis.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.wolvesville import Wolvesville
3
+ from utils.models import Emoji, EmojiCollection
4
+ from typing import List
5
+
6
+ api = Wolvesville()
7
+
8
+ collections: List[EmojiCollection] = api.getEmojiAsCollections()
9
+ emojis: List[Emoji] = api.getEmojis()
10
+
11
+ st.header("Emojis")
12
+
13
+ for emoji in emojis[:5]:
14
+ st.subheader(emoji.name.title())
15
+ st.markdown(emoji.rarity.title())
16
+ st.markdown(
17
+ f'<img src="{emoji.urlPreview}" style="height: 100px; width:100px;"/>',
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]:
25
+ st.markdown(
26
+ f'<img src="{item.promoImageUrl}" style="height: 75%; width:75%;"/>',
27
+ unsafe_allow_html=True,
28
+ )
29
+
30
+ st.markdown(
31
+ f'<img src="{item.iconUrl}" style="height: 100px; width:100px;"/>',
32
+ unsafe_allow_html=True,
33
+ )
34
+ if item.emojis != []:
35
+ with st.expander("See role icons"):
36
+ for emoji in item.emojis[:5]:
37
+ st.subheader(emoji.name.title())
38
+ st.markdown(emoji.rarity.title())
39
+ st.markdown(
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()
pages/Profile_Icons.py CHANGED
@@ -6,9 +6,9 @@ from typing import List
6
  api = Wolvesville()
7
 
8
 
9
- css_example = '''
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
11
- '''
12
  st.write(css_example, unsafe_allow_html=True)
13
 
14
 
@@ -17,7 +17,7 @@ icons: List[ProfileIcons] = api.getProfileIcons()
17
 
18
  for item in icons:
19
  rarity = item.rarity.title()
20
- HTML = f"<p><i class=\"fas fa-{item.name} fa-2xl\"></i> {rarity}</p>"
21
  st.write(HTML, unsafe_allow_html=True)
22
 
23
- st.divider()
 
6
  api = Wolvesville()
7
 
8
 
9
+ css_example = """
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
11
+ """
12
  st.write(css_example, unsafe_allow_html=True)
13
 
14
 
 
17
 
18
  for item in icons:
19
  rarity = item.rarity.title()
20
+ HTML = f'<p><i class="fas fa-{item.name} fa-2xl"></i> {rarity}</p>'
21
  st.write(HTML, unsafe_allow_html=True)
22
 
23
+ st.divider()
utils/models.py CHANGED
@@ -46,6 +46,17 @@ class Emoji(BaseModel):
46
  event: str = None
47
 
48
 
 
 
 
 
 
 
 
 
 
 
 
49
  def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
50
  emojiList = []
51
  for emoji in emojis:
@@ -57,6 +68,23 @@ def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
57
  print(emoji)
58
  return emojiList
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
62
  roleIconList = []
@@ -85,6 +113,7 @@ class LoadingScreen(BaseModel):
85
  imageWide: Image
86
  imagePrimaryColor: str
87
 
 
88
  def _getScreenObjects(screens: List[Dict[str, Union[str, Dict]]]):
89
  screenList = []
90
  for screen in screens:
@@ -96,6 +125,7 @@ def _getScreenObjects(screens: List[Dict[str, Union[str, Dict]]]):
96
  print(screen)
97
  return screenList
98
 
 
99
  class AvatarItems(BaseModel):
100
  id: str
101
  imageUrl: str
@@ -103,6 +133,7 @@ class AvatarItems(BaseModel):
103
  rarity: str
104
  costInGold: int = 0
105
 
 
106
  def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
107
  itemList = []
108
  for item in items:
@@ -114,16 +145,19 @@ def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
114
  print(item)
115
  return itemList
116
 
 
117
  class ProfileIcons(BaseModel):
118
  id: str
119
  name: str
120
  rarity: str
121
 
 
122
  def getIconName(name: str):
123
  parts = name.split(":")
124
  icon = parts[1]
125
  return icon
126
 
 
127
  def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
128
  profileIconList = []
129
  for icon in profile_icons:
@@ -135,4 +169,4 @@ def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
135
  except Exception as e:
136
  print(e)
137
  print(icon)
138
- return profileIconList
 
46
  event: str = None
47
 
48
 
49
+ class EmojiCollection(BaseModel):
50
+ id: str
51
+ emojiIds: List[str]
52
+ promoImageUrl: str
53
+ promoImagePrimaryColor: str
54
+ iconUrl: str
55
+ bonusLoadingScreenId: str
56
+ bonusMinItemCount: int
57
+ emojis: List[Emoji] = []
58
+
59
+
60
  def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
61
  emojiList = []
62
  for emoji in emojis:
 
68
  print(emoji)
69
  return emojiList
70
 
71
+ def _getEmojiCollectionObjects(emojis: List[Dict[str, Union[str, Dict]]]):
72
+ emojCollectioniList = []
73
+ for emoji in emojis:
74
+ try:
75
+ entry = EmojiCollection(**emoji)
76
+ emojCollectioniList.append(entry)
77
+ except Exception as e:
78
+ print(e)
79
+ print(emoji)
80
+ return emojCollectioniList
81
+
82
+ def _mapEmojiCollections(emojis, collections):
83
+ for item in collections:
84
+ emojiIds = item.emojiIds
85
+ emojis = [emoji for emoji in emojis if emoji.id in emojiIds]
86
+ item.emojis = emojis
87
+ return collections
88
 
89
  def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
90
  roleIconList = []
 
113
  imageWide: Image
114
  imagePrimaryColor: str
115
 
116
+
117
  def _getScreenObjects(screens: List[Dict[str, Union[str, Dict]]]):
118
  screenList = []
119
  for screen in screens:
 
125
  print(screen)
126
  return screenList
127
 
128
+
129
  class AvatarItems(BaseModel):
130
  id: str
131
  imageUrl: str
 
133
  rarity: str
134
  costInGold: int = 0
135
 
136
+
137
  def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
138
  itemList = []
139
  for item in items:
 
145
  print(item)
146
  return itemList
147
 
148
+
149
  class ProfileIcons(BaseModel):
150
  id: str
151
  name: str
152
  rarity: str
153
 
154
+
155
  def getIconName(name: str):
156
  parts = name.split(":")
157
  icon = parts[1]
158
  return icon
159
 
160
+
161
  def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
162
  profileIconList = []
163
  for icon in profile_icons:
 
169
  except Exception as e:
170
  print(e)
171
  print(icon)
172
+ return profileIconList
utils/wolvesville.py CHANGED
@@ -5,7 +5,9 @@ from utils.models import (
5
  _mapRoleRoleIcons,
6
  _getScreenObjects,
7
  _getAvatarObjects,
8
- _getProfileIconObjects
 
 
9
  )
10
  from dotenv import load_dotenv
11
  from os import getenv
@@ -44,18 +46,35 @@ class Wolvesville:
44
  emojis = requests.get(f"{self.url}/items/emojis", headers=self.headers).json()
45
  resp = _getEmojiObjects(emojis=emojis)
46
  return resp
 
 
 
 
 
47
 
 
 
 
 
 
 
48
  def getScreens(self):
49
- screens = requests.get(f"{self.url}/items/loadingScreens", headers=self.headers).json()
50
- resp = _getScreenObjects(screens=screens)
51
- return resp
 
 
52
 
53
  def getItems(self):
54
- screens = requests.get(f"{self.url}/items/avatarItems", headers=self.headers).json()
 
 
55
  resp = _getAvatarObjects(items=screens)
56
  return resp
57
-
58
  def getProfileIcons(self):
59
- icons = requests.get(f"{self.url}/items/profileIcons", headers=self.headers).json()
 
 
60
  resp = _getProfileIconObjects(profile_icons=icons)
61
- return resp
 
5
  _mapRoleRoleIcons,
6
  _getScreenObjects,
7
  _getAvatarObjects,
8
+ _getProfileIconObjects,
9
+ _getEmojiCollectionObjects,
10
+ _mapEmojiCollections
11
  )
12
  from dotenv import load_dotenv
13
  from os import getenv
 
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
 
55
+ def getEmojiAsCollections(self):
56
+ emojis = self.getEmojis()
57
+ collections = self.getEmojiCollections()
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
64
+ ).json()
65
+ resp = _getScreenObjects(screens=screens)
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
78
+ ).json()
79
  resp = _getProfileIconObjects(profile_icons=icons)
80
+ return resp