367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
60 lines
4.3 KiB
Python
60 lines
4.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Real native Warrior Rage Potion resource/cooldown fixture, no HP change.
|
|
|
|
Requires two GM-prepared5631 in root25, saved rage0 and known actual APIs.
|
|
Never compare protected UnitPower values in Lua. Original /use consumes one; finally remove remaining fixture,
|
|
restore only rage0 through legitimate GM, preserve the real cooldown to expire.
|
|
"""
|
|
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
|
|
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 resource fixture')
|
|
return p
|
|
def potion(p):return next((i for i in p['inventory']['rows'] if i['entry']==5631),None)
|
|
p=inspect();initial=potion(p)
|
|
if not initial or initial['count']!=2 or db('SELECT health,power2 FROM tw_char.characters WHERE guid=4509;')!='2609\t0':raise RuntimeError('Prepared fixture or saved baseline differs')
|
|
guid=int(initial['guid'])&0xffffffff
|
|
if db(f'SELECT guid,slot FROM tw_char.character_inventory WHERE item={guid};')!='4509\t25':raise RuntimeError('Resource fixture slot differs')
|
|
path=ROOT/'runtime/native-resource-item.json'
|
|
if path.exists():raise RuntimeError('Previous evidence preserved')
|
|
report={'pid':c.pid,'external_gateway_running':False,'hp_modified':False,'ui_review_required':True,'cleanup_pending':True,'baseline':initial,'metadata_before':p['inventory']['metadata']}
|
|
used=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:
|
|
before=p['cast_result']['count'];used=True;s.macro('/use 0 3')
|
|
def consumed():
|
|
p=inspect();r=p['cast_result'];item=potion(p)
|
|
return p if item and item['count']==1 and r['count']>before and r['spell']==6612 and r['status']==0 else None
|
|
p=c.wait(consumed,8);report['used']={k:p[k] for k in ('cast_result','item_request','inventory')};s.shot(ROOT/'runtime/native-resource-item-used.png')
|
|
s.macro('/run print("GW resource",UnitPower("player"),UnitPowerMax("player"));print("GW bag cooldown",C_Container.GetContainerItemCooldown(0,3))')
|
|
s.macro('/run local c=C_Spell.GetSpellCooldown(6612);print("GW spell cooldown",c and c.duration,c and c.startTime,c and c.isEnabled)');s.shot(ROOT/'runtime/native-resource-item-cooldown.png')
|
|
s.macro('/s .save');report['saved_state']=db('SELECT health,power2 FROM tw_char.characters WHERE guid=4509;')
|
|
report['saved_cooldown']=db('SELECT spell,item,time-UNIX_TIMESTAMP(),catTime-UNIX_TIMESTAMP() FROM tw_char.character_spell_cooldown WHERE guid=4509 AND spell=6612;')
|
|
except Exception as error:report['error']=str(error);raise
|
|
finally:
|
|
try:
|
|
p=inspect();c.wait(lambda:s.state()=='world',15);ui.key(s.d,'F1')
|
|
item=potion(p)
|
|
if item:
|
|
if item['count'] not in (1,2):raise RuntimeError('Unexpected resource count; no blind cleanup')
|
|
s.macro('/s .additem 5631 -'+str(item['count']));c.wait(lambda:not potion(inspect()),6)
|
|
if used:s.macro('/s .modify rage 0')
|
|
s.macro('/s .save');report['saved_restored_state']=c.wait(lambda:(v if (v:=db('SELECT health,power2 FROM tw_char.characters WHERE guid=4509;'))=='2609\t0' else None),6)
|
|
s.macro('/run print("GW restored resource",UnitPower("player"),UnitPowerMax("player"),UnitHealth("player"))');s.shot(ROOT/'runtime/native-resource-item-restored.png');report['cleanup_pending']=False
|
|
finally:
|
|
ui.KEY_DELAY=old;report['trace']=trace.report();path.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Actual native resource evidence requires review:',path)
|
|
if __name__=='__main__':main()
|