Files
WoW-Hybrid-gateway/ops/native_equipment_review.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

46 lines
4.1 KiB
Python

#!/usr/bin/env python3
"""Read-only original equipment tooltips for every real equipped source item.
No item grants, equipment changes, character changes or fabricated responses.
Screenshots require human/agent review; this tool does not equate capture with
metadata/effect correctness. Source values and exact live slots accompany them.
"""
import argparse,json,time
from pathlib import Path
from client_session import Session
import client_ui as ui
from local_tortoise import db
from native_engine_character_test import ROOT,Controller,local_listeners
from native_test_guard import require_local_turtle_ports,require_solo_test_character,require_authenticated_turtle_realm,require_native_gameplay_policy
from native_vendor_buy_test import inventory
def main():
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--character',type=int,required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args();out=a.output.resolve()
if not out.is_relative_to(ROOT/'runtime') or out.exists() or not 0<a.character<2**32:p.error('Require new runtime directory and bounded disposable character ID')
require_local_turtle_ports(local_listeners());require_solo_test_character(a.character,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
c=Controller(int((ROOT/'runtime/native-client.pid').read_text()));require_authenticated_turtle_realm(c.rpc('inspect-wire-account'));require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'))
columns=['name','required_level','armor','max_count','max_durability','sell_price']+[prefix+str(i) for i in range(1,11) for prefix in ('stat_type','stat_value')]+[prefix+str(i) for i in range(1,6) for prefix in ('spellid_','spelltrigger_')]
fields="'slot',ci.slot,'entry',ii.itemEntry,"+','.join("'"+v+"',t.`"+v+'`' for v in columns)
raw=db('SELECT HEX(JSON_OBJECT('+fields+f')) FROM tw_char.character_inventory ci JOIN tw_char.item_instance ii ON ci.item=ii.guid JOIN tw_world.item_template t ON t.entry=ii.itemEntry WHERE ci.guid={a.character} AND ci.bag=0 AND ci.slot<19 ORDER BY ci.slot;')
equipped=[json.loads(bytes.fromhex(line)) for line in raw.splitlines()]
if not 1<=len(equipped)<=19 or len({r['slot'] for r in equipped})!=len(equipped):raise RuntimeError('Unsupported/ambiguous equipped source slots')
baseline=inventory(a.character);state=lambda:db(f'SELECT level,health,power2,money FROM tw_char.characters WHERE guid={a.character};')
report=dict(pid=c.pid,character=a.character,external_gateway_running=False,before_inventory=baseline,before_state=state(),source_equipped=equipped,screenshots=[],actual_ui_review_required=True,items_automatically_asserted_correct=False)
out.mkdir(mode=0o700);old=ui.KEY_DELAY;failure=None;started=time.monotonic()
try:
with Session(c.pid) as s:
s.wait_world();s.focus();ui.KEY_DELAY=.03
for item in equipped:
slot=item['slot']+1;path=out/f'{slot:02}-{item["entry"]}.png'
command=f'/run GameTooltip:SetOwner(UIParent,"ANCHOR_NONE");GameTooltip:ClearAllPoints();GameTooltip:SetPoint("CENTER");GameTooltip:SetInventoryItem("player",{slot});print("GW slot",{slot},GetInventoryItemID("player",{slot}))'
s.macro(command);s.shot(path);report['screenshots'].append(dict(slot=slot,entry=item['entry'],path=path.name));print('Captured original equipment tooltip',slot,item['entry'],flush=True)
s.macro('/run GameTooltip:Hide()')
pipe=c.rpc('inspect-engine-pipe');report.update(after_inventory=inventory(a.character),after_state=state(),pipe_error=pipe['error'],pipe_closed=pipe['closed'],elapsed_seconds=round(time.monotonic()-started,3))
if report['after_inventory']!=baseline or report['after_state']!=report['before_state'] or pipe['error'] or pipe['closed']:raise RuntimeError('Source baseline/native connection changed during read-only review')
except Exception as e:failure=type(e).__name__+': '+str(e);report['failure']=failure
finally:ui.KEY_DELAY=old
(out/'result.json').write_text(json.dumps(report,indent=2)+'\n');(out/'result.json').chmod(0o600)
print(json.dumps({k:report.get(k) for k in ('pid','before_state','after_state','elapsed_seconds','actual_ui_review_required','failure')}))
return 0 if not failure else 2
if __name__=='__main__':raise SystemExit(main())