Spaces:
Sleeping
Sleeping
Abhinav
commited on
feat: Support Loading Screens
Browse files- pages/roles.py +13 -6
- pages/screens.py +21 -0
- utils/models.py +24 -1
- utils/wolvesville.py +14 -3
pages/roles.py
CHANGED
@@ -10,15 +10,22 @@ roles: List[Role] = api.getRoleRoleIcons()
|
|
10 |
st.title("Roles")
|
11 |
|
12 |
for role in roles[:5]:
|
13 |
-
st.markdown(
|
14 |
-
|
|
|
|
|
|
|
15 |
st.subheader(role.name)
|
16 |
-
|
17 |
-
st.
|
|
|
18 |
|
19 |
if role.icons != []:
|
20 |
with st.expander("See role icons"):
|
21 |
for icon in role.icons:
|
22 |
-
st.markdown(
|
|
|
|
|
|
|
23 |
|
24 |
-
st.divider()
|
|
|
10 |
st.title("Roles")
|
11 |
|
12 |
for role in roles[:5]:
|
13 |
+
st.markdown(
|
14 |
+
f'<img src="{role.image.url}" style="height: 100px; width:100px;"/>',
|
15 |
+
unsafe_allow_html=True,
|
16 |
+
)
|
17 |
+
|
18 |
st.subheader(role.name)
|
19 |
+
aura = role.aura.title()
|
20 |
+
st.markdown(aura)
|
21 |
+
st.markdown(role.description)
|
22 |
|
23 |
if role.icons != []:
|
24 |
with st.expander("See role icons"):
|
25 |
for icon in role.icons:
|
26 |
+
st.markdown(
|
27 |
+
f'<img src="{icon}" style="height: 100px; width:100px;"/>',
|
28 |
+
unsafe_allow_html=True,
|
29 |
+
)
|
30 |
|
31 |
+
st.divider()
|
pages/screens.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from utils.wolvesville import Wolvesville
|
3 |
+
from utils.models import LoadingScreen
|
4 |
+
from typing import List
|
5 |
+
|
6 |
+
api = Wolvesville()
|
7 |
+
|
8 |
+
screens: List[LoadingScreen] = api.getScreens()
|
9 |
+
|
10 |
+
st.title("Loading Screens")
|
11 |
+
|
12 |
+
for screen in screens[:5]:
|
13 |
+
st.markdown(
|
14 |
+
f'<img src="{screen.image.url}" style="height:75%; width:75%;"/>',
|
15 |
+
unsafe_allow_html=True,
|
16 |
+
)
|
17 |
+
|
18 |
+
rarity = screen.rarity.title()
|
19 |
+
st.markdown(rarity)
|
20 |
+
|
21 |
+
st.divider()
|
utils/models.py
CHANGED
@@ -17,12 +17,14 @@ class Role(BaseModel):
|
|
17 |
image: Image
|
18 |
icons: List[str] = None
|
19 |
|
|
|
20 |
class RoleIcon(BaseModel):
|
21 |
id: str
|
22 |
rarity: str
|
23 |
image: Image
|
24 |
roleId: str
|
25 |
|
|
|
26 |
def _getRoleObjects(roles: List[Dict[str, Union[str, Dict]]]):
|
27 |
roleList = []
|
28 |
for role in roles:
|
@@ -55,6 +57,7 @@ def _getEmojiObjects(emojis: List[Dict[str, Union[str, Dict]]]):
|
|
55 |
print(emoji)
|
56 |
return emojiList
|
57 |
|
|
|
58 |
def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
|
59 |
roleIconList = []
|
60 |
for icon in icons:
|
@@ -66,9 +69,29 @@ def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
|
|
66 |
print(icon)
|
67 |
return roleIconList
|
68 |
|
|
|
69 |
def _mapRoleRoleIcons(roles, icons):
|
70 |
for role in roles:
|
71 |
id = role.id
|
72 |
iconList = [icon.image.url for icon in icons if icon.roleId == id]
|
73 |
role.icons = iconList
|
74 |
-
return roles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
image: Image
|
18 |
icons: List[str] = None
|
19 |
|
20 |
+
|
21 |
class RoleIcon(BaseModel):
|
22 |
id: str
|
23 |
rarity: str
|
24 |
image: Image
|
25 |
roleId: str
|
26 |
|
27 |
+
|
28 |
def _getRoleObjects(roles: List[Dict[str, Union[str, Dict]]]):
|
29 |
roleList = []
|
30 |
for role in roles:
|
|
|
57 |
print(emoji)
|
58 |
return emojiList
|
59 |
|
60 |
+
|
61 |
def _getRoleIconObjects(icons: List[Dict[str, Union[str, Dict]]]):
|
62 |
roleIconList = []
|
63 |
for icon in icons:
|
|
|
69 |
print(icon)
|
70 |
return roleIconList
|
71 |
|
72 |
+
|
73 |
def _mapRoleRoleIcons(roles, icons):
|
74 |
for role in roles:
|
75 |
id = role.id
|
76 |
iconList = [icon.image.url for icon in icons if icon.roleId == id]
|
77 |
role.icons = iconList
|
78 |
+
return roles
|
79 |
+
|
80 |
+
|
81 |
+
class LoadingScreen(BaseModel):
|
82 |
+
id: str
|
83 |
+
rarity: str
|
84 |
+
image: Image
|
85 |
+
imageWide: Image
|
86 |
+
imagePrimaryColor: str
|
87 |
+
|
88 |
+
def _getScreenObjects(screens: List[Dict[str, Union[str, Dict]]]):
|
89 |
+
screenList = []
|
90 |
+
for screen in screens:
|
91 |
+
try:
|
92 |
+
entry = LoadingScreen(**screen)
|
93 |
+
screenList.append(entry)
|
94 |
+
except Exception as e:
|
95 |
+
print(e)
|
96 |
+
print(screen)
|
97 |
+
return screenList
|
utils/wolvesville.py
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
-
from utils.models import
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from dotenv import load_dotenv
|
3 |
from os import getenv
|
4 |
import requests
|
@@ -20,7 +26,7 @@ class Wolvesville:
|
|
20 |
roles = data["roles"]
|
21 |
resp = _getRoleObjects(roles=roles)
|
22 |
return resp
|
23 |
-
|
24 |
def getRoleIcons(self):
|
25 |
data = requests.get(f"{self.url}/items/roleIcons", headers=self.headers).json()
|
26 |
resp = _getRoleIconObjects(icons=data)
|
@@ -31,8 +37,13 @@ class Wolvesville:
|
|
31 |
icons = self.getRoleIcons()
|
32 |
mapping = _mapRoleRoleIcons(roles=roles, icons=icons)
|
33 |
return mapping
|
34 |
-
|
35 |
def getEmojis(self):
|
36 |
emojis = requests.get(f"{self.url}/items/emojis", headers=self.headers).json()
|
37 |
resp = _getEmojiObjects(emojis=emojis)
|
38 |
return resp
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from utils.models import (
|
2 |
+
_getRoleObjects,
|
3 |
+
_getEmojiObjects,
|
4 |
+
_getRoleIconObjects,
|
5 |
+
_mapRoleRoleIcons,
|
6 |
+
_getScreenObjects
|
7 |
+
)
|
8 |
from dotenv import load_dotenv
|
9 |
from os import getenv
|
10 |
import requests
|
|
|
26 |
roles = data["roles"]
|
27 |
resp = _getRoleObjects(roles=roles)
|
28 |
return resp
|
29 |
+
|
30 |
def getRoleIcons(self):
|
31 |
data = requests.get(f"{self.url}/items/roleIcons", headers=self.headers).json()
|
32 |
resp = _getRoleIconObjects(icons=data)
|
|
|
37 |
icons = self.getRoleIcons()
|
38 |
mapping = _mapRoleRoleIcons(roles=roles, icons=icons)
|
39 |
return mapping
|
40 |
+
|
41 |
def getEmojis(self):
|
42 |
emojis = requests.get(f"{self.url}/items/emojis", headers=self.headers).json()
|
43 |
resp = _getEmojiObjects(emojis=emojis)
|
44 |
return resp
|
45 |
+
|
46 |
+
def getScreens(self):
|
47 |
+
screens = requests.get(f"{self.url}/items/loadingScreens", headers=self.headers).json()
|
48 |
+
resp = _getScreenObjects(screens=screens)
|
49 |
+
return resp
|