367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
60 lines
4.1 KiB
Python
60 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Controlled local native healing-item integration, never a stat gameplay feature.
|
|
|
|
Requires disposable4509 at saved2609/2609, prepared one118 potion in root25,
|
|
normal SUCCEEDED event observer installed, authenticated native world and active
|
|
send policy. Uses original /use; GM only reduces/restores HP and saves. Screenshots
|
|
and trace require review, including natural regeneration versus the heal event.
|
|
"""
|
|
import json,os
|
|
from client_session import Session
|
|
from native_engine_character_test import Controller,ROOT,local_listeners
|
|
from native_test_guard import require_local_turtle_ports,require_authenticated_turtle_realm,require_native_gameplay_policy
|
|
from native_world_trace import WorldTrace
|
|
from local_tortoise import db,private
|
|
import client_ui as ui
|
|
|
|
def main():
|
|
os.umask(0o077);require_local_turtle_ports(local_listeners())
|
|
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'))
|
|
def inspect():
|
|
p=c.rpc('inspect-engine-pipe')
|
|
if p['error'] or p['closed']:raise RuntimeError('Native session lost; preserve recovery record')
|
|
return p
|
|
if db('SELECT health FROM tw_char.characters WHERE guid=4509;')!='2609':raise RuntimeError('Saved baseline differs; no HP change issued')
|
|
p=inspect();potions=[i for i in p['inventory']['rows'] if i['entry']==118]
|
|
if len(potions)!=1 or potions[0]['count']!=1:raise RuntimeError('Require one prepared real potion')
|
|
guid=int(potions[0]['guid'])&0xffffffff
|
|
if db(f'SELECT guid,slot FROM tw_char.character_inventory WHERE item={guid};')!='4509\t25':raise RuntimeError('Potion fixture slot differs')
|
|
path=ROOT/'runtime/native-healing-item.json'
|
|
if path.exists():raise RuntimeError('Preserve previous evidence before another controlled test')
|
|
report={'pid':c.pid,'baseline_health':2609,'baseline_max_health':2609,'potion_guid':guid,'external_gateway_running':False,'restoration_pending':False,'review_required':True}
|
|
restore=False
|
|
with Session(c.pid) as s,WorldTrace(c) as trace:
|
|
c.wait(lambda:s.state()=='world',15);s.focus();old=ui.KEY_DELAY;ui.KEY_DELAY=.03
|
|
try:
|
|
ui.key(s.d,'F1');restore=True;report['restoration_pending']=True
|
|
s.macro('/s .modify hp 1000 2609')
|
|
s.macro('/run print("GW before potion",UnitHealth("player"),UnitHealthMax("player"))');s.shot(ROOT/'runtime/native-healing-item-injured.png')
|
|
baseline=inspect()['cast_result']['count'];s.macro('/use 0 3')
|
|
def used():
|
|
p=inspect();r=p['cast_result'];return p if not any(i['entry']==118 for i in p['inventory']['rows']) and r['count']>baseline and r['spell']==439 and r['status']==0 else None
|
|
p=c.wait(used,8);report['used']={k:p[k] for k in ('cast_result','item_request','inventory')}
|
|
s.macro('/run print("GW after potion",UnitHealth("player"),UnitHealthMax("player"));print("GW cast idle",UnitCastingInfo("player"))');s.shot(ROOT/'runtime/native-healing-item-healed.png')
|
|
s.macro('/s .save');report['saved_after_use_health']=db('SELECT health FROM tw_char.characters WHERE guid=4509;')
|
|
except Exception as error:
|
|
report['error']=str(error);raise
|
|
finally:
|
|
try:
|
|
if restore:
|
|
inspect();c.wait(lambda:s.state()=='world',15)
|
|
ui.key(s.d,'F1');s.macro('/s .modify hp 2609 2609');s.macro('/s .save')
|
|
report['saved_restored_health']=c.wait(lambda:(v if (v:=db('SELECT health FROM tw_char.characters WHERE guid=4509;'))=='2609' else None),6)
|
|
report['restoration_pending']=False
|
|
s.macro('/run print("GW restored HP",UnitHealth("player"),UnitHealthMax("player"))');s.shot(ROOT/'runtime/native-healing-item-restored.png')
|
|
finally:
|
|
ui.KEY_DELAY=old;report['trace']=trace.report();path.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Controlled real healing-item evidence saved:',path)
|
|
if __name__=='__main__':main()
|