32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Waffen- und Aufsatz-Katalog fürs Map-Loadout aus dem Match-Server-Repo holen.
|
|
|
|
Aufruf: python3 tools/sync_loadout_katalog.py [pfad/zu/scopedvr-match-server]
|
|
Schreibt library/loadout_katalog.json (Waffen-ID -> Name, Aufsatz-Slots).
|
|
Nach neuen Waffen/Aufsätzen im Server erneut ausführen.
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
hier = os.path.dirname(os.path.abspath(__file__))
|
|
server = sys.argv[1] if len(sys.argv) > 1 else os.path.expanduser("~/godot-projects/scopedvr-match-server")
|
|
profile = json.load(open(os.path.join(server, "library/weapons.json"), encoding="utf-8"))["profiles"]
|
|
aufsaetze = json.load(open(os.path.join(server, "library/attachments.json"), encoding="utf-8"))["weapons"]
|
|
|
|
waffen = {}
|
|
for wid in sorted(profile):
|
|
p = profile[wid]
|
|
eintrag = {"name": str(p.get("name", wid))}
|
|
if wid in aufsaetze:
|
|
eintrag["slots"] = {
|
|
s: {"default": d.get("default", ""), "optional": bool(d.get("optional", False)),
|
|
"options": list(d.get("options", []))}
|
|
for s, d in sorted(aufsaetze[wid].items())
|
|
}
|
|
waffen[wid] = eintrag
|
|
|
|
ziel = os.path.join(hier, "..", "library", "loadout_katalog.json")
|
|
with open(ziel, "w", encoding="utf-8") as f:
|
|
json.dump({"version": 1, "waffen": waffen}, f, ensure_ascii=False, indent=1, sort_keys=True)
|
|
print("%d Waffen -> %s" % (len(waffen), os.path.normpath(ziel)))
|