-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcosmetics.py
71 lines (58 loc) · 1.86 KB
/
cosmetics.py
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
# putting this here since it will probably get messy
from flask import Blueprint, render_template
from flask_login import login_required
from json import load
GAMEVER_BW = 0
GAMEVER_B2W2 = 1
cosmetics = Blueprint("cosmetics", __name__)
class GenericContent(object):
def __init__(self, name, fname, idx, gamever):
self.name = name
self.type = "generic"
self.gamever = gamever
self.fname = fname
self._idx = idx
@classmethod
def from_json(cls, json_data, gamever):
return cls(
json_data["display_name"],
json_data["filename"],
json_data["index"],
gamever,
)
class Skin(GenericContent):
def __init__(self, name, fname, idx, preview_img, gamever):
super().__init__(name, fname, idx, gamever)
self.type = "skin"
self.image_url = preview_img
@classmethod
def from_json(cls, json_data, gamever):
return cls(
json_data["display_name"],
json_data["filename"],
json_data["index"],
json_data["preview"],
gamever,
)
class Musical(GenericContent):
def __init__(self, name, fname, idx, gamever):
super().__init__(name, fname, idx, gamever)
self.type = "musical"
@classmethod
def from_json(cls, json_data, gamever):
return cls(
json_data["display_name"],
json_data["filename"],
json_data["index"],
gamever,
)
@cosmetics.route("/select/gear")
@login_required
def select_gear():
skins = [
Skin.from_json(x, GAMEVER_BW)
for x in load(open("dls1/CGEAR2/listing.json"))["content"]
]
return render_template(
"select_gearskin2.html.jinja2", title="Select C-Gear Skin", skins=skins
)