diff --git a/data/clean/31-0/data.sqlite3 b/data/clean/31-0/data.sqlite3 index 56bacbf..afdf522 100644 Binary files a/data/clean/31-0/data.sqlite3 and b/data/clean/31-0/data.sqlite3 differ diff --git a/data/convert/31-0/db.py b/data/convert/31-0/db.py index f8d801d..ebcceef 100644 --- a/data/convert/31-0/db.py +++ b/data/convert/31-0/db.py @@ -8,3 +8,4 @@ class Melee(db.Entity): description = Optional(str) mechanism = Optional(str) icon = Required(bytes) + stats = Required(int) diff --git a/data/convert/31-0/melee.py b/data/convert/31-0/melee.py index f3b1661..3588744 100755 --- a/data/convert/31-0/melee.py +++ b/data/convert/31-0/melee.py @@ -51,9 +51,16 @@ with db_session: 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]] + Melee( name=i["name"], description=i["ambiantDesc"], mechanism=i["gameplayDesc"], - icon=region_arr.getbuffer().tobytes() + icon=region_arr.getbuffer().tobytes(), + stats=stats, ) diff --git a/data/render/README.md b/data/render/README.md new file mode 100644 index 0000000..4b1c2d6 --- /dev/null +++ b/data/render/README.md @@ -0,0 +1,9 @@ +# 数据渲染 + +将数据导出为图片 + +`server.py` 是用 Bottle 写的后端,运行 `./server.py` 然后打开 就能看到怨恨之刃的网页。 + +之所以不直接用模板渲染,而要用 Web 服务器,是为了方便开发。 + +运行 `render_all.py` 会渲染所有近战武器,输出到 `output` 文件夹中。 diff --git a/data/render/output/串刺之剑.png b/data/render/output/串刺之剑.png new file mode 100644 index 0000000..3cdac55 Binary files /dev/null and b/data/render/output/串刺之剑.png differ diff --git a/data/render/output/冥河提灯.png b/data/render/output/冥河提灯.png new file mode 100644 index 0000000..1af215e Binary files /dev/null and b/data/render/output/冥河提灯.png differ diff --git a/data/render/output/利润匕首.png b/data/render/output/利润匕首.png new file mode 100644 index 0000000..0421cd3 Binary files /dev/null and b/data/render/output/利润匕首.png differ diff --git a/data/render/output/刺剑.png b/data/render/output/刺剑.png new file mode 100644 index 0000000..251adbe Binary files /dev/null and b/data/render/output/刺剑.png differ diff --git a/data/render/output/刺客匕首.png b/data/render/output/刺客匕首.png new file mode 100644 index 0000000..b0c1439 Binary files /dev/null and b/data/render/output/刺客匕首.png differ diff --git a/data/render/output/化境.png b/data/render/output/化境.png new file mode 100644 index 0000000..5ceb23e Binary files /dev/null and b/data/render/output/化境.png differ diff --git a/data/render/output/双匕首.png b/data/render/output/双匕首.png new file mode 100644 index 0000000..04386da Binary files /dev/null and b/data/render/output/双匕首.png differ diff --git a/data/render/output/双截锅.png b/data/render/output/双截锅.png new file mode 100644 index 0000000..18abab5 Binary files /dev/null and b/data/render/output/双截锅.png differ diff --git a/data/render/output/固化光剑.png b/data/render/output/固化光剑.png new file mode 100644 index 0000000..8f586fb Binary files /dev/null and b/data/render/output/固化光剑.png differ diff --git a/data/render/output/均衡之刃.png b/data/render/output/均衡之刃.png new file mode 100644 index 0000000..25b52a0 Binary files /dev/null and b/data/render/output/均衡之刃.png differ diff --git a/data/render/output/墓碑.png b/data/render/output/墓碑.png new file mode 100644 index 0000000..64dd60e Binary files /dev/null and b/data/render/output/墓碑.png differ diff --git a/data/render/output/夜歌(手持).png b/data/render/output/夜歌(手持).png new file mode 100644 index 0000000..6a0b7b8 Binary files /dev/null and b/data/render/output/夜歌(手持).png differ diff --git a/data/render/output/大剑.png b/data/render/output/大剑.png new file mode 100644 index 0000000..9a7ab7d Binary files /dev/null and b/data/render/output/大剑.png differ diff --git a/data/render/output/对称长枪.png b/data/render/output/对称长枪.png new file mode 100644 index 0000000..6eb9277 Binary files /dev/null and b/data/render/output/对称长枪.png differ diff --git a/data/render/output/巨人杀手.png b/data/render/output/巨人杀手.png new file mode 100644 index 0000000..fa57042 Binary files /dev/null and b/data/render/output/巨人杀手.png differ diff --git a/data/render/output/巨镰利爪.png b/data/render/output/巨镰利爪.png new file mode 100644 index 0000000..8fb7d38 Binary files /dev/null and b/data/render/output/巨镰利爪.png differ diff --git a/data/render/output/巨镰左爪.png b/data/render/output/巨镰左爪.png new file mode 100644 index 0000000..646719f Binary files /dev/null and b/data/render/output/巨镰左爪.png differ diff --git a/data/render/output/带刃双拐.png b/data/render/output/带刃双拐.png new file mode 100644 index 0000000..386583a Binary files /dev/null and b/data/render/output/带刃双拐.png differ diff --git a/data/render/output/平底锅.png b/data/render/output/平底锅.png new file mode 100644 index 0000000..fa41aee Binary files /dev/null and b/data/render/output/平底锅.png differ diff --git a/data/render/output/开发者武器.png b/data/render/output/开发者武器.png new file mode 100644 index 0000000..b665774 Binary files /dev/null and b/data/render/output/开发者武器.png differ diff --git a/data/render/output/弩柄攻击.png b/data/render/output/弩柄攻击.png new file mode 100644 index 0000000..cc0fd98 Binary files /dev/null and b/data/render/output/弩柄攻击.png differ diff --git a/data/render/output/怨恨之刃.png b/data/render/output/怨恨之刃.png new file mode 100644 index 0000000..8c53f65 Binary files /dev/null and b/data/render/output/怨恨之刃.png differ diff --git a/data/render/output/战矛.png b/data/render/output/战矛.png new file mode 100644 index 0000000..1710762 Binary files /dev/null and b/data/render/output/战矛.png differ diff --git a/data/render/output/损坏的牙签.png b/data/render/output/损坏的牙签.png new file mode 100644 index 0000000..d8f4454 Binary files /dev/null and b/data/render/output/损坏的牙签.png differ diff --git a/data/render/output/撬棍.png b/data/render/output/撬棍.png new file mode 100644 index 0000000..982698c Binary files /dev/null and b/data/render/output/撬棍.png differ diff --git a/data/render/output/斯巴达草鞋.png b/data/render/output/斯巴达草鞋.png new file mode 100644 index 0000000..8eb5be1 Binary files /dev/null and b/data/render/output/斯巴达草鞋.png differ diff --git a/data/render/output/施虐者匕首.png b/data/render/output/施虐者匕首.png new file mode 100644 index 0000000..1ea9469 Binary files /dev/null and b/data/render/output/施虐者匕首.png differ diff --git a/data/render/output/服部的武士刀.png b/data/render/output/服部的武士刀.png new file mode 100644 index 0000000..8b17ee5 Binary files /dev/null and b/data/render/output/服部的武士刀.png differ diff --git a/data/render/output/油腻之剑.png b/data/render/output/油腻之剑.png new file mode 100644 index 0000000..f778983 Binary files /dev/null and b/data/render/output/油腻之剑.png differ diff --git a/data/render/output/深海巨口.png b/data/render/output/深海巨口.png new file mode 100644 index 0000000..0f24207 Binary files /dev/null and b/data/render/output/深海巨口.png differ diff --git a/data/render/output/深渊三叉戟.png b/data/render/output/深渊三叉戟.png new file mode 100644 index 0000000..684d145 Binary files /dev/null and b/data/render/output/深渊三叉戟.png differ diff --git a/data/render/output/火把.png b/data/render/output/火把.png new file mode 100644 index 0000000..8677543 Binary files /dev/null and b/data/render/output/火把.png differ diff --git a/data/render/output/烤炉之斧.png b/data/render/output/烤炉之斧.png new file mode 100644 index 0000000..bc92fab Binary files /dev/null and b/data/render/output/烤炉之斧.png differ diff --git a/data/render/output/燧石.png b/data/render/output/燧石.png new file mode 100644 index 0000000..511de6d Binary files /dev/null and b/data/render/output/燧石.png differ diff --git a/data/render/output/牙签.png b/data/render/output/牙签.png new file mode 100644 index 0000000..23e3954 Binary files /dev/null and b/data/render/output/牙签.png differ diff --git a/data/render/output/狂暴之刃.png b/data/render/output/狂暴之刃.png new file mode 100644 index 0000000..022e49f Binary files /dev/null and b/data/render/output/狂暴之刃.png differ diff --git a/data/render/output/王后刺剑.png b/data/render/output/王后刺剑.png new file mode 100644 index 0000000..983f8ba Binary files /dev/null and b/data/render/output/王后刺剑.png differ diff --git a/data/render/output/瓦尔蒙特长鞭.png b/data/render/output/瓦尔蒙特长鞭.png new file mode 100644 index 0000000..257fb03 Binary files /dev/null and b/data/render/output/瓦尔蒙特长鞭.png differ diff --git a/data/render/output/生锈的刀.png b/data/render/output/生锈的刀.png new file mode 100644 index 0000000..6d18d4d Binary files /dev/null and b/data/render/output/生锈的刀.png differ diff --git a/data/render/output/砍刀与手枪.png b/data/render/output/砍刀与手枪.png new file mode 100644 index 0000000..f149f26 Binary files /dev/null and b/data/render/output/砍刀与手枪.png differ diff --git a/data/render/output/破坏球.png b/data/render/output/破坏球.png new file mode 100644 index 0000000..209e348 Binary files /dev/null and b/data/render/output/破坏球.png differ diff --git a/data/render/output/碎裂手斧.png b/data/render/output/碎裂手斧.png new file mode 100644 index 0000000..f3e0cdf Binary files /dev/null and b/data/render/output/碎裂手斧.png differ diff --git a/data/render/output/纯粹骨钉.png b/data/render/output/纯粹骨钉.png new file mode 100644 index 0000000..80ecd3f Binary files /dev/null and b/data/render/output/纯粹骨钉.png differ diff --git a/data/render/output/缠绕鞭.png b/data/render/output/缠绕鞭.png new file mode 100644 index 0000000..ad35813 Binary files /dev/null and b/data/render/output/缠绕鞭.png differ diff --git a/data/render/output/胡桃夹子.png b/data/render/output/胡桃夹子.png new file mode 100644 index 0000000..9c6c434 Binary files /dev/null and b/data/render/output/胡桃夹子.png differ diff --git a/data/render/output/节奏布祖基琴.png b/data/render/output/节奏布祖基琴.png new file mode 100644 index 0000000..a050a4c Binary files /dev/null and b/data/render/output/节奏布祖基琴.png differ diff --git a/data/render/output/蛇牙.png b/data/render/output/蛇牙.png new file mode 100644 index 0000000..78b81e5 Binary files /dev/null and b/data/render/output/蛇牙.png differ diff --git a/data/render/output/血之刃.png b/data/render/output/血之刃.png new file mode 100644 index 0000000..8097f02 Binary files /dev/null and b/data/render/output/血之刃.png differ diff --git a/data/render/output/触手.png b/data/render/output/触手.png new file mode 100644 index 0000000..72d7749 Binary files /dev/null and b/data/render/output/触手.png differ diff --git a/data/render/output/诅咒之刃.png b/data/render/output/诅咒之刃.png new file mode 100644 index 0000000..1adac13 Binary files /dev/null and b/data/render/output/诅咒之刃.png differ diff --git a/data/render/output/迅捷之剑.png b/data/render/output/迅捷之剑.png new file mode 100644 index 0000000..fc361bd Binary files /dev/null and b/data/render/output/迅捷之剑.png differ diff --git a/data/render/output/钉入矛.png b/data/render/output/钉入矛.png new file mode 100644 index 0000000..8dc6b90 Binary files /dev/null and b/data/render/output/钉入矛.png differ diff --git a/data/render/output/钉鞋.png b/data/render/output/钉鞋.png new file mode 100644 index 0000000..ba6591d Binary files /dev/null and b/data/render/output/钉鞋.png differ diff --git a/data/render/output/铁扇.png b/data/render/output/铁扇.png new file mode 100644 index 0000000..95c57ac Binary files /dev/null and b/data/render/output/铁扇.png differ diff --git a/data/render/output/铁杖.png b/data/render/output/铁杖.png new file mode 100644 index 0000000..920c630 Binary files /dev/null and b/data/render/output/铁杖.png differ diff --git a/data/render/output/铁钩手.png b/data/render/output/铁钩手.png new file mode 100644 index 0000000..fff5de5 Binary files /dev/null and b/data/render/output/铁钩手.png differ diff --git a/data/render/output/铲子.png b/data/render/output/铲子.png new file mode 100644 index 0000000..580fe77 Binary files /dev/null and b/data/render/output/铲子.png differ diff --git a/data/render/output/隼之拳套.png b/data/render/output/隼之拳套.png new file mode 100644 index 0000000..7ab44c7 Binary files /dev/null and b/data/render/output/隼之拳套.png differ diff --git a/data/render/output/隼之靴.png b/data/render/output/隼之靴.png new file mode 100644 index 0000000..07ed46f Binary files /dev/null and b/data/render/output/隼之靴.png differ diff --git a/data/render/output/震地之刃.png b/data/render/output/震地之刃.png new file mode 100644 index 0000000..c3c9b9c Binary files /dev/null and b/data/render/output/震地之刃.png differ diff --git a/data/render/output/骨头.png b/data/render/output/骨头.png new file mode 100644 index 0000000..2e38663 Binary files /dev/null and b/data/render/output/骨头.png differ diff --git a/data/render/output/黄金匕首.png b/data/render/output/黄金匕首.png new file mode 100644 index 0000000..848dadb Binary files /dev/null and b/data/render/output/黄金匕首.png differ diff --git a/data/render/render_all.py b/data/render/render_all.py new file mode 100755 index 0000000..393513a --- /dev/null +++ b/data/render/render_all.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# # -*- coding: utf-8 -*- + +import sys +from playwright.sync_api import sync_playwright + +sys.path.append("../convert/31-0") +from db import * + +db.bind(provider="sqlite", filename="../clean/31-0/data.sqlite3") +db.generate_mapping(create_tables=True) + +with sync_playwright() as p: + browser = p.chromium.launch() + page = browser.new_page() + with db_session: + for m in Melee.select(): + print(f"rendering {m.name}...") + page.goto(f"http://localhost:8080/{m.name}") + page.locator(".container").screenshot(path=f"./output/{m.name}.png") + browser.close() diff --git a/data/render/server.py b/data/render/server.py new file mode 100755 index 0000000..11515da --- /dev/null +++ b/data/render/server.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# # -*- coding: utf-8 -*- + +import sys +import base64 +import re +from bottle import route, run, static_file, view + +sys.path.append("../convert/31-0") +from db import * + +db.bind(provider="sqlite", filename="../clean/31-0/data.sqlite3") +db.generate_mapping(create_tables=True) + + +@route("/") +@view("weapon") +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 + ) + stats_map = { + 1: "brutality", + 2: "survival", + 3: "minotaur", + 4: "tactics", + 5: "assassin", + 6: "guardian", + } + return { + "title": name, + "icon": base64.b64encode(weapon.icon), + "mechanism": mechanism, + "description": weapon.description, + "stats": stats_map[weapon.stats] + } + + +@route("/static/") +def server_static(filepath): + return static_file(filepath, root="./static") + + +run(host="localhost", port=8080) diff --git a/data/render/static/Infobox-background.webp b/data/render/static/Infobox-background.webp new file mode 100644 index 0000000..2000a6f Binary files /dev/null and b/data/render/static/Infobox-background.webp differ diff --git a/data/render/static/Table-border.webp b/data/render/static/Table-border.webp new file mode 100644 index 0000000..40fdcc9 Binary files /dev/null and b/data/render/static/Table-border.webp differ diff --git a/data/render/static/bg/assassin.png b/data/render/static/bg/assassin.png new file mode 100644 index 0000000..5582982 Binary files /dev/null and b/data/render/static/bg/assassin.png differ diff --git a/data/render/static/bg/brutality.png b/data/render/static/bg/brutality.png new file mode 100644 index 0000000..e070af2 Binary files /dev/null and b/data/render/static/bg/brutality.png differ diff --git a/data/render/static/bg/guardian.png b/data/render/static/bg/guardian.png new file mode 100644 index 0000000..d1d9e42 Binary files /dev/null and b/data/render/static/bg/guardian.png differ diff --git a/data/render/static/bg/minotaur.png b/data/render/static/bg/minotaur.png new file mode 100644 index 0000000..b00e9a3 Binary files /dev/null and b/data/render/static/bg/minotaur.png differ diff --git a/data/render/static/bg/survival.png b/data/render/static/bg/survival.png new file mode 100644 index 0000000..603f493 Binary files /dev/null and b/data/render/static/bg/survival.png differ diff --git a/data/render/static/bg/tactics.png b/data/render/static/bg/tactics.png new file mode 100644 index 0000000..4c99997 Binary files /dev/null and b/data/render/static/bg/tactics.png differ diff --git a/data/render/static/style.css b/data/render/static/style.css new file mode 100644 index 0000000..ff203ee --- /dev/null +++ b/data/render/static/style.css @@ -0,0 +1,131 @@ +body { + background: rgba(7, 12, 25, 0.85); + margin: 0; +} + +.container { + box-sizing: border-box; + width: 350px; + border: 1px solid transparent; + border-image: url("/static/Table-border.webp"); + border-image-width: 15px; + border-image-slice: 15 16; + border-radius: 5px; + padding: 6px; + background: rgba(21, 30, 61, 0.7); + background-image: url("/static/Infobox-background.webp"); + background-position: bottom right; + background-repeat: no-repeat; +} + +.title { + background: rgba(6, 9, 19, 0.5); + font-family: "Noto Sans CJK SC"; + font-weight: bold; + color: #f7eb62; + font-size: 18px; + line-height: 1.6; + text-align: center; + letter-spacing: 4px; +} + +.weapon-icon-bg { + margin: 5px; + padding: 10px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + image-rendering: pixelated; + display: flex; + justify-content: center; +} + +.weapon-icon { + width: 72px; + height: 72px; +} + +.mechanism { + padding: 2px 16px; + color: #e0e0e0; + text-align: center; + font-size: 14px; + font-family: "Noto Sans CJK SC"; + line-height: 1.7; +} + +.CC { + color: #f0d60d; +} + +.BL { + color: #e03e35; +} + +.RO { + color: #82a082; +} + +.TO { + color: #75dc2c; +} + +.FI { + color: #e5822b; +} + +.EL { + color: #37a3d7; +} + +.IC { + color: #91d5fb; +} + +.description { + padding: 2px 16px; + color: #90abe6; + text-align: center; + font-size: 14px; + font-family: "Noto Sans CJK SC"; + line-height: 1.7; +} + +.subtitle { + color: #e0e0e0; + background: rgba(6, 9, 19, 0.5); + text-align: center; + font-family: "Noto Sans CJK SC"; + font-weight: bold; + line-height: 1.8; + font-size: 18px; +} + +.dps { + padding: 10px 40px; + display: flex; + justify-content: center; + gap: 20px; +} + +.table { + color: #e0e0e0; + margin: 2px auto; + text-align: center; + border-collapse: collapse; +} + +.table > tbody > tr:nth-child(odd) { + background: rgba(6, 9, 19, 0.1); +} + +.table > tbody > tr > td { + font-size: 16px; + font-family: "Noto Sans CJK SC"; + line-height: 28px; + padding: 2px 10px; +} + +.summary > td:first-child { + font-weight: bold; +} diff --git a/data/render/views/weapon.tpl b/data/render/views/weapon.tpl new file mode 100644 index 0000000..fa93d40 --- /dev/null +++ b/data/render/views/weapon.tpl @@ -0,0 +1,26 @@ + + + + + + Template + + + +
+
{{ title }}
+
+ +
+ % if mechanism: +
{{ !mechanism }}
+ % end + % if description: +
{{ description }}
+ %end +
+ +