Files
TSSBOT/scripts/gen_sample_scoreboards.py
NotSoToothless 7bd8a1b72c -am (#1329)
2026-06-17 00:32:30 -07:00

38 lines
1.2 KiB
Python

"""Render scoreboards for every replay in TSSBOT/replays_sample/ for visual review.
Run from the TSSBOT dir: python -m scripts.gen_sample_scoreboards
Outputs <session>/scoreboard.png next to each replay_data.json.
"""
import asyncio
import glob
import json
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from BOT import transform, scoreboard # noqa: E402
async def main():
files = sorted(glob.glob("replays_sample/*/replay_data.json"))
if not files:
print("No sample replays found under replays_sample/")
return
for f in files:
with open(f, encoding="utf-8") as fh:
game = json.load(fh)
model = transform.build_scoreboard_model(game, "<English>")
if not model:
print(f"SKIP {f}: model build returned None")
continue
out = os.path.join(os.path.dirname(f), "scoreboard.png")
# bar_color "not_set": no guild team context in this offline render.
await scoreboard.create_scoreboard(model, out, bar_color="not_set")
size = os.path.getsize(out)
print(f"OK {model['map']:<22} {model['session_id']} -> {out} ({size//1024} KB)")
if __name__ == "__main__":
asyncio.run(main())