KAZIK/tools/tests/check_street_population.py
Artvasil09 4f8ae0893b Implement native slots, coin toss, European roulette and hall furniture
Add native assembly scenes and assets for Slots (777), Coin flip, and European Roulette; add 3D hall furniture packs and prompts; improve Russian UI strings in CP1251; update launcher hash and rebuild shipping binaries.
2026-10-10 14:43:30 +03:00

45 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():
data = (OUTPUT / "street-visibility-v5.bin").read_bytes()
pixels = struct.unpack(f"<{len(data)//4}I", data)
assert len(pixels) == 14
visibility = dict(zip(PROPS + [f"walker_{i+1}" for i in range(6)], 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, six outdoor walkers; no plants;")
print("seven distinct native route snapshots; " + json.dumps(visibility))
if __name__ == "__main__":
main()