🗃️ Rendered 31-2 data, added shields
16
data/convert/31-2/db.py
Normal file → Executable file
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# # -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pony.orm import *
|
from pony.orm import *
|
||||||
|
|
||||||
db = Database()
|
db = Database()
|
||||||
|
@ -9,3 +12,16 @@ class Melee(db.Entity):
|
||||||
mechanism = Optional(str)
|
mechanism = Optional(str)
|
||||||
icon = Required(bytes)
|
icon = Required(bytes)
|
||||||
stats = Required(int)
|
stats = Required(int)
|
||||||
|
|
||||||
|
|
||||||
|
class Shield(db.Entity):
|
||||||
|
name = Required(str)
|
||||||
|
description = Optional(str)
|
||||||
|
mechanism = Optional(str)
|
||||||
|
icon = Required(bytes)
|
||||||
|
stats = Required(int)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
|
||||||
|
db.generate_mapping(create_tables=True)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import re
|
||||||
import io
|
import io
|
||||||
from db import *
|
from db import *
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from playwright.sync_api import sync_playwright
|
|
||||||
|
|
||||||
with open("../../extraction/raw-31-2/data.cdb.json") as f:
|
with open("../../extraction/raw-31-2/data.cdb.json") as f:
|
||||||
raw = json.load(f)
|
raw = json.load(f)
|
||||||
|
@ -15,7 +14,7 @@ with open("../../clean/31-2/main.zh.mo.json") as f:
|
||||||
img = Image.open("../../extraction/raw-31-2/cardIcons.png")
|
img = Image.open("../../extraction/raw-31-2/cardIcons.png")
|
||||||
|
|
||||||
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
|
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
|
||||||
db.generate_mapping(create_tables=True)
|
db.generate_mapping()
|
||||||
|
|
||||||
lines = raw["sheets"][1]["lines"]
|
lines = raw["sheets"][1]["lines"]
|
||||||
|
|
||||||
|
|
68
data/convert/31-2/shield.py
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# # -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import io
|
||||||
|
from db import *
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
with open("../../extraction/raw-31-2/data.cdb.json") as f:
|
||||||
|
raw = json.load(f)
|
||||||
|
with open("../../clean/31-2/main.zh.mo.json") as f:
|
||||||
|
trans = json.load(f)
|
||||||
|
img = Image.open("../../extraction/raw-31-2/cardIcons.png")
|
||||||
|
|
||||||
|
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
|
||||||
|
db.generate_mapping()
|
||||||
|
|
||||||
|
lines = raw["sheets"][1]["lines"]
|
||||||
|
|
||||||
|
with db_session:
|
||||||
|
for i in lines:
|
||||||
|
if i["group"] == 6:
|
||||||
|
i["name"] = trans[i["name"]]["msgstr"][0]
|
||||||
|
if "ambiantDesc" in i:
|
||||||
|
i["ambiantDesc"] = trans[i["ambiantDesc"].strip()]["msgstr"][0]
|
||||||
|
else:
|
||||||
|
i["ambiantDesc"] = ""
|
||||||
|
if "gameplayDesc" in i:
|
||||||
|
i["gameplayDesc"] = trans[i["gameplayDesc"].strip()]["msgstr"][0]
|
||||||
|
if i["props"]:
|
||||||
|
|
||||||
|
def replace_props(m):
|
||||||
|
prop_name = m.group(1)
|
||||||
|
if prop_name == "ShockAffectDuration":
|
||||||
|
prop_name = "duration2" # 雷盾带电手动触发
|
||||||
|
result = i["props"][prop_name]
|
||||||
|
if isinstance(result, list):
|
||||||
|
result = result[0]
|
||||||
|
if not isinstance(result, str):
|
||||||
|
result = str(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
i["gameplayDesc"], _ = re.subn(
|
||||||
|
r"::[\+|\*]?(.*?)::", replace_props, i["gameplayDesc"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
i["gameplayDesc"] = ""
|
||||||
|
x = i["icon"]["x"] * 24
|
||||||
|
y = i["icon"]["y"] * 24
|
||||||
|
box = (x, y, x + 24, y + 24)
|
||||||
|
region = img.crop(box)
|
||||||
|
region_arr = io.BytesIO()
|
||||||
|
region.save(region_arr, format="PNG")
|
||||||
|
|
||||||
|
stats_map = {"Brutality": 1, "Survival": 2, "Tactic": 4}
|
||||||
|
stats = 0
|
||||||
|
for t in ["tier1", "tier2"]:
|
||||||
|
if t in i:
|
||||||
|
stats += stats_map[i[t]]
|
||||||
|
|
||||||
|
Shield(
|
||||||
|
name=i["name"],
|
||||||
|
description=i["ambiantDesc"],
|
||||||
|
mechanism=i["gameplayDesc"],
|
||||||
|
icon=region_arr.getbuffer().tobytes(),
|
||||||
|
stats=stats,
|
||||||
|
)
|
BIN
data/render/31-2/output/击晕盾.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
data/render/31-2/output/前线盾.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
data/render/31-2/output/力场盾.png
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
data/render/31-2/output/反击盾.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
data/render/31-2/output/壁垒.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
data/render/31-2/output/寒冰盾.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
data/render/31-2/output/带刺盾.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
data/render/31-2/output/惩罚.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
data/render/31-2/output/猛推盾.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
data/render/31-2/output/突击盾.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
data/render/31-2/output/老木盾.png
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
data/render/31-2/output/贪婪盾.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
data/render/31-2/output/雷盾.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
data/render/31-2/output/鲜血盾.png
Normal file
After Width: | Height: | Size: 76 KiB |
|
@ -14,7 +14,7 @@ with sync_playwright() as p:
|
||||||
browser = p.chromium.launch()
|
browser = p.chromium.launch()
|
||||||
page = browser.new_page(device_scale_factor=3)
|
page = browser.new_page(device_scale_factor=3)
|
||||||
with db_session:
|
with db_session:
|
||||||
for m in Melee.select():
|
for m in [*Melee.select(), *Shield.select()]:
|
||||||
print(f"rendering {m.name}...")
|
print(f"rendering {m.name}...")
|
||||||
page.goto(f"http://localhost:8080/{m.name}")
|
page.goto(f"http://localhost:8080/{m.name}")
|
||||||
page.locator(".container").screenshot(path=f"./output/{m.name}.png")
|
page.locator(".container").screenshot(path=f"./output/{m.name}.png")
|
||||||
|
|
|
@ -18,10 +18,17 @@ db.generate_mapping()
|
||||||
def melee(name):
|
def melee(name):
|
||||||
with db_session:
|
with db_session:
|
||||||
query = select(w for w in Melee if w.name == name)
|
query = select(w for w in Melee if w.name == name)
|
||||||
|
if query.count() > 0:
|
||||||
weapon = query.first()
|
weapon = query.first()
|
||||||
|
else:
|
||||||
|
query = select(w for w in Shield if w.name == name)
|
||||||
|
weapon = query.first()
|
||||||
|
if weapon.mechanism:
|
||||||
mechanism, _ = re.subn(
|
mechanism, _ = re.subn(
|
||||||
r"{(.*?)@(.*?)}", r"<span class='\2'>\1</span>", weapon.mechanism
|
r"{(.*?)@(.*?)}", r"<span class='\2'>\1</span>", weapon.mechanism
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
mechanism = ""
|
||||||
stats_map = {
|
stats_map = {
|
||||||
1: "brutality",
|
1: "brutality",
|
||||||
2: "survival",
|
2: "survival",
|
||||||
|
@ -35,7 +42,7 @@ def melee(name):
|
||||||
"icon": base64.b64encode(weapon.icon),
|
"icon": base64.b64encode(weapon.icon),
|
||||||
"mechanism": mechanism,
|
"mechanism": mechanism,
|
||||||
"description": weapon.description,
|
"description": weapon.description,
|
||||||
"stats": stats_map[weapon.stats]
|
"stats": stats_map[weapon.stats],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|