KAZIK/tools/generators/pack_slot_assets.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

52 lines
2.3 KiB
Python

"""Normalize generated slot art and export ANM1 packs for the MASM runtime."""
import json
import struct
from pathlib import Path
from PIL import Image
ROOT = Path(__file__).resolve().parents[2]
SOURCE = ROOT / "assets/sprites/slots"
OUTPUT = ROOT / "assets/animations/slots"
def pack(name, frames):
width, height = frames[0].size
assert all(frame.size == (width, height) for frame in frames)
pixels = b"".join(frame.tobytes("raw", "BGRA") for frame in frames)
(OUTPUT / name).write_bytes(struct.pack("<4s4I", b"ANM1", width, height,
len(frames), len(pixels)) + pixels)
def main():
OUTPUT.mkdir(parents=True, exist_ok=True)
cabinet = Image.open(SOURCE / "cabinet-v1.png").convert("RGBA")
cabinet = cabinet.resize((640, 480), Image.Resampling.NEAREST)
pack("cabinet-v1.bin", [cabinet])
sheet = Image.open(SOURCE / "symbols-v1.png").convert("RGBA")
assert 1.8 < sheet.width / sheet.height < 2.2
symbols = []
for index in range(8):
column, row = index % 4, index // 4
cell = sheet.crop((round(column * sheet.width / 4), round(row * sheet.height / 2),
round((column + 1) * sheet.width / 4), round((row + 1) * sheet.height / 2)))
bounds = cell.getchannel("A").getbbox()
assert bounds, f"Empty symbol {index}"
cell = cell.crop(bounds)
cell.thumbnail((52, 52), Image.Resampling.NEAREST)
frame = Image.new("RGBA", (64, 64))
frame.paste(cell, ((64 - cell.width) // 2, (64 - cell.height) // 2))
# Opaque pixel clusters allow the native clipped reel sampler to stay cheap.
frame.putalpha(frame.getchannel("A").point(lambda value: 255 if value >= 128 else 0))
symbols.append(frame)
pack("symbols-v1.bin", symbols)
manifest = {"symbols": ["seven", "cherries", "lemon", "bell", "BAR",
"grapes", "diamond", "crown"],
"cabinet": [640, 480], "symbol": [64, 64],
"pipeline": "offline normalization only; gameplay and reel animation are MASM"}
(OUTPUT / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="ascii")
print("Packed native 777 cabinet and 8 alpha-tested 64x64 reel symbols")
if __name__ == "__main__":
main()