KAZIK/tools/tests/check_durak_frames.py
Artvasil09 3ad5bf4c9d Develop assembly-only casino scenes and native games
Add native Durak, poker, blackjack, roulette, Buckshot and billiards scenes with animation assets and regression tests. Improve arrival, city, hall, profiles, shops, audio and exit handling; remove the portable C game core and refresh shipping executables.
2026-10-08 22:39:19 +03:00

44 lines
1.8 KiB
Python

"""Inspect actual ASM framebuffers, not an independently simulated renderer."""
from pathlib import Path
import hashlib
from PIL import Image
ROOT = Path(__file__).resolve().parents[2]
OUT = ROOT / "build/actions"
def main():
names = ("ready", "deal", "attack", "defense", "flight", "taking",
"result", "long-hand", "exit")
frames = {}
hashes = set()
for name in names:
frame = Image.open(OUT / f"durak-{name}.bmp").convert("RGB")
assert frame.size == (640, 480), name
assert len(frame.getcolors(640 * 480)) > 1000, name
header = (10, 14, 16) if name == "exit" else (21, 29, 32)
assert frame.getpixel((0, 0)) == header, name
digest = hashlib.sha256(frame.tobytes()).digest()
assert digest not in hashes, f"Duplicate scene: {name}"
hashes.add(digest)
frames[name] = frame
frame.save(OUT / f"durak-{name}.png")
# The modal freezes a paid hand, and is inside the same 640x480 framebuffer.
assert frames["exit"].getpixel((44, 136)) == (21, 29, 32)
assert frames["exit"].getpixel((68, 306)) == (45, 73, 61)
assert frames["exit"].getpixel((336, 306)) == (73, 49, 48)
# Long hand shows only the last four cards, not a card fan escaping the screen.
for x in (20, 55, 90, 125):
region = frames["long-hand"].crop((x * 2, 336, (x + 34) * 2, 430))
assert len(region.getcolors(34 * 2 * 94)) >= 3
assert frames["long-hand"].getpixel((x * 2 + 16, 380)) == (238, 237, 226)
# Both pagers have the same frame/fill coordinates as their actual hitboxes.
assert frames["long-hand"].getpixel((5, 365)) == (213, 199, 158)
assert frames["long-hand"].getpixel((609, 365)) == (213, 199, 158)
print("PASS: nine distinct native Durak phases, modal/button bounds, paged 36-card hand")
if __name__ == "__main__":
main()