Files
patchnotes/shipdisplays.py
2025-12-30 18:58:23 +01:00

98 lines
2.1 KiB
Python

import json
with open("./mrlar/data/ships.json") as f:
ship_data = json.load(f)
with open("./mrlar/data/skins.json") as f:
skin_data = json.load(f)
with open("output", "r") as f:
lines = f.read().strip().splitlines()
hulls = {
0: "Unknown",
1: "DD",
2: "CL",
3: "CA",
4: "BC",
5: "BB",
6: "CVL",
7: "CV",
8: "SS",
9: "CAV",
10: "BBV",
11: "CT",
12: "AR",
13: "BM",
14: "TRP",
15: "Cargo",
16: "Bomb",
17: "SSV",
18: "CB",
19: "AE",
20: "DDGv",
21: "DDGm",
22: "IXs",
23: "IXv",
24: "IXm",
25: "Special",
}
out = []
for line in lines:
if not "ShipDisplay" in line:
print(line)
continue
# {{ShipDisplay|6|Gouden Leeuw|CV|Maid|An Intimate Cleaning |{{Gem}} 1|L2D+|142}}
_, _, name, _, category, skin, _, _, _ = line.split("|")
name = name.strip()
skin = skin.strip()
try:
curr_ship = next(item[1] for item in ship_data.items() if item[1]["name"] == name)
curr_skin = next(item[1] for item in skin_data.items() if item[1]["name"] == skin)
except:
print(*map(str.encode, (name, skin)))
exit()
# [x] rarity
rarity = curr_ship["rarity"]
# [x] hull type
hull = hulls[curr_ship["hull"]]
# [ ] skin category (probably impossible?)
# afaik this is impossible (without more information that probably exists)
# so this is done by hand for now
# category = curr_skin["category"]
# [x] gem price
price = curr_skin["price"]
# [x] skin type
skin_type = ""
if curr_skin["dynamic"]: skin_type = "DYN"
if curr_skin["dual_form"]: skin_type = "DUAL"
if curr_skin["l2d"]: skin_type = "L2D"
if curr_skin["l2d_plus"]: skin_type = "L2D+"
# [x] skin background
skin_bg = curr_skin["bg"]
# [ ] reconstruct shipdisplay line
out = "|".join(map(str, (
"{{ShipDisplay",
rarity,
name,
hull,
category,
skin,
"{{Gem}} " + str(price),
skin_type,
skin_bg,
"}}"
)))
print(out)