KAZIK/tools/tests/check_blackjack_party.py
Artvasil09 881a0061dc Add native NPC visitors with contracts, Clover slots, Pyramid, and party table scenes
Implement 32x32 BFS visitor navigation and daily contracts system with companion .npc journals; add native assembly scenes for Clover slots, Pyramid cards, Blackjack Party and Russian Party; package animation and sprite packs; add comprehensive offline test suites and rebuild shipping binaries.
2026-10-13 09:47:33 +03:00

61 lines
2.8 KiB
Python

"""Inspect native party table captures and compare tested/shipping MASM."""
import argparse
import hashlib
from pathlib import Path
from PIL import Image, ImageChops, ImageDraw, ImageStat
from check_card_exit_build import Coff
ROOT = Path(__file__).resolve().parents[2]
def frames():
names = ["1", "2", "3", "flight", "result", "exit"]
sheet = Image.new("RGB", (1280, 3 * 504), (20, 25, 29))
draw = ImageDraw.Draw(sheet)
signatures = []
captured = {}
for i, name in enumerate(names):
path = ROOT / "build/actions" / f"blackjack-party-{name}.bmp"
image = Image.open(path).convert("RGB")
captured[name] = image
assert image.size == (640, 480)
assert len(image.getcolors(640 * 480)) > 1000, name
assert sum(ImageStat.Stat(image.crop((0, 444, 640, 476))).stddev) > 10, name
signatures.append(hashlib.sha256(image.tobytes()).digest())
image.save(path.with_suffix(".png"))
x, y = (i % 2) * 640, (i // 2) * 504
sheet.paste(image, (x, y + 24))
draw.text((x + 8, y + 6), f"Native blackjack: {name}", fill="white")
assert len(set(signatures)) == len(names)
for number, box in (("2", (248, 132, 392, 240)), ("3", (472, 132, 616, 240))):
difference = ImageChops.difference(captured[number].crop(box), captured["1"].crop(box))
assert sum(ImageStat.Stat(difference).mean) > 15, f"Guest {number} did not render"
sheet.save(ROOT / "build/actions/blackjack-party-contact.png")
print("PASS: six distinct native party-table captures, visible portraits, cards, controls and exit modal")
def parity():
tested = Coff(ROOT / "build/actions/actions-test.obj")
shipping = Coff(ROOT / "build/graphics/poker.obj")
for name, size in (("InitBJParty3D", 0), ("FreeBJParty3D", 0), ("DealBJParty3D", 0),
("FinishBJPlayer3D", 4), ("BeginBJDealer3D", 0),
("BJBotDecision3D", 4), ("UpdateBJParty3D", 0),
("ResolveBJParty3D", 0), ("BJPartyInput3D", 0),
("SetBJPartyCount3D", 4), ("RenderBJParty3D", 0),
("DrawBJPartySelector3D", 0), ("DrawBJMiniCard3D", 16),
("DrawBJMiniFlight3D", 16), ("NativeBJSettle3D", 4),
("StartNativeBlackjack3D", 0), ("HandleNativeBlackjack3D", 0),
("RenderNativeBlackjack3D", 0)):
symbol = f"_{name}@{size}"
assert tested.signature(symbol) == shipping.signature(symbol), name
print("PASS: shipping party dealing, AI, settlement, animation and input match native-tested MASM")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--parity", action="store_true")
args = parser.parse_args()
frames()
if args.parity:
parity()