diff --git a/data/clean/31-2/data.sqlite3 b/data/clean/31-2/data.sqlite3
index afdf522..cd2c3f9 100644
Binary files a/data/clean/31-2/data.sqlite3 and b/data/clean/31-2/data.sqlite3 differ
diff --git a/data/convert/31-2/db.py b/data/convert/31-2/db.py
old mode 100644
new mode 100755
index ebcceef..b262dd3
--- a/data/convert/31-2/db.py
+++ b/data/convert/31-2/db.py
@@ -1,3 +1,6 @@
+#!/usr/bin/env python3
+# # -*- coding: utf-8 -*-
+
from pony.orm import *
db = Database()
@@ -9,3 +12,16 @@ class Melee(db.Entity):
mechanism = Optional(str)
icon = Required(bytes)
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)
diff --git a/data/convert/31-2/melee.py b/data/convert/31-2/melee.py
index c6cf1f4..19c667c 100755
--- a/data/convert/31-2/melee.py
+++ b/data/convert/31-2/melee.py
@@ -6,7 +6,6 @@ import re
import io
from db import *
from PIL import Image
-from playwright.sync_api import sync_playwright
with open("../../extraction/raw-31-2/data.cdb.json") as 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")
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
-db.generate_mapping(create_tables=True)
+db.generate_mapping()
lines = raw["sheets"][1]["lines"]
diff --git a/data/convert/31-2/shield.py b/data/convert/31-2/shield.py
new file mode 100755
index 0000000..e3bb0d9
--- /dev/null
+++ b/data/convert/31-2/shield.py
@@ -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,
+ )
diff --git a/data/render/31-2/output/击晕盾.png b/data/render/31-2/output/击晕盾.png
new file mode 100644
index 0000000..b7da1f6
Binary files /dev/null and b/data/render/31-2/output/击晕盾.png differ
diff --git a/data/render/31-2/output/前线盾.png b/data/render/31-2/output/前线盾.png
new file mode 100644
index 0000000..d6d72a4
Binary files /dev/null and b/data/render/31-2/output/前线盾.png differ
diff --git a/data/render/31-2/output/力场盾.png b/data/render/31-2/output/力场盾.png
new file mode 100644
index 0000000..4c32323
Binary files /dev/null and b/data/render/31-2/output/力场盾.png differ
diff --git a/data/render/31-2/output/反击盾.png b/data/render/31-2/output/反击盾.png
new file mode 100644
index 0000000..6d217de
Binary files /dev/null and b/data/render/31-2/output/反击盾.png differ
diff --git a/data/render/31-2/output/壁垒.png b/data/render/31-2/output/壁垒.png
new file mode 100644
index 0000000..1e3cd51
Binary files /dev/null and b/data/render/31-2/output/壁垒.png differ
diff --git a/data/render/31-2/output/寒冰盾.png b/data/render/31-2/output/寒冰盾.png
new file mode 100644
index 0000000..6fa7613
Binary files /dev/null and b/data/render/31-2/output/寒冰盾.png differ
diff --git a/data/render/31-2/output/带刺盾.png b/data/render/31-2/output/带刺盾.png
new file mode 100644
index 0000000..2eba216
Binary files /dev/null and b/data/render/31-2/output/带刺盾.png differ
diff --git a/data/render/31-2/output/惩罚.png b/data/render/31-2/output/惩罚.png
new file mode 100644
index 0000000..ee53d08
Binary files /dev/null and b/data/render/31-2/output/惩罚.png differ
diff --git a/data/render/31-2/output/猛推盾.png b/data/render/31-2/output/猛推盾.png
new file mode 100644
index 0000000..59748ae
Binary files /dev/null and b/data/render/31-2/output/猛推盾.png differ
diff --git a/data/render/31-2/output/突击盾.png b/data/render/31-2/output/突击盾.png
new file mode 100644
index 0000000..b0016b2
Binary files /dev/null and b/data/render/31-2/output/突击盾.png differ
diff --git a/data/render/31-2/output/老木盾.png b/data/render/31-2/output/老木盾.png
new file mode 100644
index 0000000..5c70552
Binary files /dev/null and b/data/render/31-2/output/老木盾.png differ
diff --git a/data/render/31-2/output/贪婪盾.png b/data/render/31-2/output/贪婪盾.png
new file mode 100644
index 0000000..10fcb54
Binary files /dev/null and b/data/render/31-2/output/贪婪盾.png differ
diff --git a/data/render/31-2/output/雷盾.png b/data/render/31-2/output/雷盾.png
new file mode 100644
index 0000000..c4bc0c3
Binary files /dev/null and b/data/render/31-2/output/雷盾.png differ
diff --git a/data/render/31-2/output/鲜血盾.png b/data/render/31-2/output/鲜血盾.png
new file mode 100644
index 0000000..f38bd23
Binary files /dev/null and b/data/render/31-2/output/鲜血盾.png differ
diff --git a/data/render/31-2/render_all.py b/data/render/31-2/render_all.py
index 5020fb1..e7ab194 100755
--- a/data/render/31-2/render_all.py
+++ b/data/render/31-2/render_all.py
@@ -14,7 +14,7 @@ with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(device_scale_factor=3)
with db_session:
- for m in Melee.select():
+ for m in [*Melee.select(), *Shield.select()]:
print(f"rendering {m.name}...")
page.goto(f"http://localhost:8080/{m.name}")
page.locator(".container").screenshot(path=f"./output/{m.name}.png")
diff --git a/data/render/31-2/server.py b/data/render/31-2/server.py
index 29f544d..3744e6d 100755
--- a/data/render/31-2/server.py
+++ b/data/render/31-2/server.py
@@ -18,10 +18,17 @@ db.generate_mapping()
def melee(name):
with db_session:
query = select(w for w in Melee if w.name == name)
- weapon = query.first()
- mechanism, _ = re.subn(
- r"{(.*?)@(.*?)}", r"\1", weapon.mechanism
- )
+ if query.count() > 0:
+ weapon = query.first()
+ else:
+ query = select(w for w in Shield if w.name == name)
+ weapon = query.first()
+ if weapon.mechanism:
+ mechanism, _ = re.subn(
+ r"{(.*?)@(.*?)}", r"\1", weapon.mechanism
+ )
+ else:
+ mechanism = ""
stats_map = {
1: "brutality",
2: "survival",
@@ -35,7 +42,7 @@ def melee(name):
"icon": base64.b64encode(weapon.icon),
"mechanism": mechanism,
"description": weapon.description,
- "stats": stats_map[weapon.stats]
+ "stats": stats_map[weapon.stats],
}