#!/usr/bin/env python3 """anim_manifest.py NOTES: write anim/manifest.json (accepted animations per creature) and the per-sheet status/notes into anim/progress.json. NOTES lines: -|accepted|skipped|note""" import json, os, sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) from make_anim import BY_ID, ANIM, update_progress # noqa: E402 ORDER = ["imp"] + [c for c in BY_ID if c != "imp"] notes = {} for line in open(sys.argv[1]): if line.strip(): sheet, status, note = line.rstrip("\n").split("|", 2) notes[sheet] = (status, note) # the pilot sheets for s in ("knight-walk", "knight-attack", "kobold-walk", "kobold-attack"): notes.setdefault(s, ("accepted", "pilot (see the pilot section)")) man = [] for cid in ORDER: anims = [a for a in ("walk", "die", "attack") if notes.get(f"{cid}-{a}", ("",))[0] == "accepted" and os.path.exists(os.path.join(ANIM, f"{cid}-{a}-32.png"))] man.append({"id": cid, "kind": BY_ID[cid]["kind"], "anims": anims}) json.dump(man, open(os.path.join(ANIM, "manifest.json"), "w"), indent=1) def f(d): for sheet, (status, note) in notes.items(): e = d["sheets"].setdefault(sheet, {"images": 0}) e["status"], e["note"] = status, note for sheet, e in d["sheets"].items(): if e.get("status") == "generating": e["status"] = "unreviewed" update_progress(f) print(sum(len(m["anims"]) for m in man), "sheets in the manifest")