Files
zelda-1-prometeu-port/tools/validate_real_secret_captures.py

34 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Native wall/secret-cave pixels, including submenu and persistent reload."""
import json
from PIL import Image
from extract_graphics import ROOT
from nes_object_graphics import item
from validate_octorok_graphics import native_image
out=ROOT/'extracted/real_secret';caps=out/'validation';checks=[]
def validate(name,ref,ignore=(),offset=0,rupee=False):
actual=Image.open(caps/(name+'.png')).convert('RGBA');assert actual.getpixel((0,0))==(0,255,0,255),name
expected=Image.open(ref).convert('RGBA')
if rupee:
# Fixture clock is zero: the existing item animator selects blue palette 1.
info=item(22);info=dict(info,attributes=[(a&252)|1 for a in info['attributes']]);expected.paste((0,0,0,255),(120,153,136,169));expected.alpha_composite(native_image(info),(120,153))
bad=[]
for y in range(64+offset,240):
for x in range(256):
if any(x0<=x<x1 and y0<=y<y1 for x0,y0,x1,y1 in ignore):continue
if actual.getpixel((112+x,15+y))!=expected.getpixel((x,y-offset)):bad.append((x,y))
assert not bad,(name,len(bad),bad[:4]);checks.append({'capture':name,'different_pixels':0})
validate('wall-closed',ROOT/'extracted/overworld/north/room.png',[(112,109,128,129)])
validate('wall-open',out/'north-open.png',[(80,80,160,140)]) # Live bomb/effect around the portal; tested closed/open via raw tile assertions.
validate('cave-ready',out/'cave_available.png',[(112,173,128,193)],rupee=True)
validate('reward-credited',out/'cave_claimed.png',[(120,157,136,177)],rupee=True)
validate('cave-menu',out/'cave_available.png',offset=58,rupee=True)
validate('revisit',out/'cave_revisit.png',[(112,173,128,193)])
validate('reload-north',out/'north-open.png',[(112,109,128,129)])
validate('reload-cave',out/'cave_revisit.png',[(112,109,128,129)])
for p in caps.glob('*.png'):
if p.name.startswith(('production-','prod-')):continue
assert Image.open(p).getpixel((0,0))==(0,255,0,255),p.name
assert Image.open(caps/'save-durable.png').getpixel((1,0))==(0,255,0,255)
(out/'capture-report.json').write_text(json.dumps({'checks':checks,'durable_commit':True,'reload':True},indent=2)+'\n');print('Native pixel checks:',len(checks),'all exact; commit/reload assertions green')