KAZIK/tools/tests/check_street_population.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

43 lines
1.8 KiB
Python

"""Check visibility measured by actual MASM pixels along the arrival route."""
import hashlib
import json
import struct
from pathlib import Path
from PIL import Image, ImageDraw
ROOT = Path(__file__).resolve().parents[2]
OUTPUT = ROOT / "build/actions"
PROPS = ["bench", "hydrant", "mailbox", "newspaper_box", "bollard",
"planter", "parking_meter", "fence"]
def main():
pixels = struct.unpack("<12I", (OUTPUT / "street-visibility-v5.bin").read_bytes())
visibility = dict(zip(PROPS + ["walker_1", "walker_2", "walker_3", "walker_4"], pixels))
assert pixels[5] == 0, ('Plants must be removed', visibility)
assert min(pixels[:5] + pixels[6:]) >= 128, visibility
names = [f"street-v5-{index}" for index in range(6)] + ["street-v5-door"]
sheet = Image.new("RGB", (1280, 4 * 505), "#181e22")
labels = ImageDraw.Draw(sheet)
frames = {}
for index, name in enumerate(names):
frame = Image.open(OUTPUT / (name + ".bmp")).convert("RGB")
assert frame.size == (640, 480)
assert len(frame.getcolors(640 * 480)) > 100
frames[name] = hashlib.sha256(frame.tobytes()).hexdigest()
frame.save(OUTPUT / (name + ".png"))
x, y = index % 2 * 640, index // 2 * 505
labels.text((x + 8, y + 5), name, fill="white")
sheet.paste(frame, (x, y + 25))
assert len(set(frames.values())) == len(names)
sheet.save(OUTPUT / "street-v5-contact.png")
(OUTPUT / "street-v5-qa.json").write_text(
json.dumps({"visible_pixels": visibility, "native_frames": frames}, indent=2),
encoding="ascii")
print("PASS: two world-geometry benches, six other street prop types, four walkers; no plants;")
print("seven distinct native route snapshots; " + json.dumps(visibility))
if __name__ == "__main__":
main()