367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
71 lines
4.6 KiB
Python
71 lines
4.6 KiB
Python
#!/usr/bin/env python3
|
|
"""User-requested local Warrior outfit through genuine GM grants and client equip.
|
|
|
|
Preserves displaced items; no SQL writes, permission edits or inventory deletion.
|
|
Idempotent by actual owned entries/positions. Fixture IDs verified from local DB;
|
|
this is test setup, not proof of vendors, trainer learning, set procs or tooltips.
|
|
"""
|
|
import argparse,datetime,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 local_tortoise import db
|
|
import client_ui as ui
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser();parser.add_argument('--stage',choices=['bags','gear'],required=True);args=parser.parse_args()
|
|
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'] or p['inventory'].get('truncated'):raise RuntimeError('Native inventory unavailable; no blind item grant')
|
|
return p
|
|
def owned(entry):return [i for i in inspect()['inventory']['rows'] if i['entry']==entry]
|
|
def records(entry):
|
|
text=db(f'SELECT ci.item,ci.bag,ci.slot FROM tw_char.character_inventory ci JOIN tw_char.item_instance ii ON ii.guid=ci.item WHERE ci.guid=4509 AND ii.itemEntry={entry} ORDER BY ci.bag,ci.slot;')
|
|
return [tuple(map(int,row.split('\t'))) for row in text.splitlines()]
|
|
report={'pid':c.pid,'external_gateway_running':False,'stage':args.stage,'steps':[],'complete':False,'displaced_items_preserved':True}
|
|
path=ROOT/'runtime'/('requested-gear-'+datetime.datetime.now().strftime('%Y%m%d-%H%M%S')+'.json')
|
|
with Session(c.pid) as s:
|
|
c.wait(lambda:s.state()=='world',15);s.focus();old=ui.KEY_DELAY;ui.KEY_DELAY=.03
|
|
def grant(entry,count):
|
|
current=sum(i['count'] for i in owned(entry))
|
|
if current>count:raise RuntimeError('More matching items than requested; no removal')
|
|
if current<count:
|
|
s.macro(f'/s .additem {entry} {count-current}')
|
|
c.wait(lambda:sum(i['count'] for i in owned(entry))==count,6)
|
|
s.macro('/s .save');c.wait(lambda:len(records(entry))==count,6)
|
|
def equip(entry,guid,target):
|
|
row=next(r for r in records(entry) if r[0]==guid)
|
|
if row[1:]==(0,target):return
|
|
if row[1]!=0 or not 23<=row[2]<39:raise RuntimeError('Equip fixture outside root backpack; preserve for inspection')
|
|
previous=inspect()['cast_result']['inventory_count']
|
|
s.macro(f'/run C_Container.UseContainerItem(0,{row[2]-23+1})')
|
|
s.macro('/s .save')
|
|
try:c.wait(lambda:any(r==(guid,0,target) for r in records(entry)),6)
|
|
except RuntimeError:
|
|
error=inspect()['cast_result'];report['equip_failure']={'entry':entry,'source':row,'target':target,'server_error':error if error['inventory_count']>previous else None};raise
|
|
report['steps'].append({'entry':entry,'guid':guid,'slot':target,'server_saved':True})
|
|
path.write_text(json.dumps(report,indent=2)+'\n')
|
|
try:
|
|
ui.key(s.d,'F1')
|
|
if args.stage=='bags':
|
|
# Four original16-slot Traveler's Backpacks, not client-only slots.
|
|
grant(4500,4)
|
|
used={r[2] for r in records(4500) if r[1]==0 and 19<=r[2]<23}
|
|
for guid,bag,slot in records(4500):
|
|
if bag==0 and 19<=slot<23:continue
|
|
target=next(i for i in range(19,23) if i not in used)
|
|
equip(4500,guid,target);used.add(target)
|
|
s.macro('/run print("GW bag slots",C_Container.GetContainerNumSlots(1),C_Container.GetContainerNumSlots(2),C_Container.GetContainerNumSlots(3),C_Container.GetContainerNumSlots(4))')
|
|
else:
|
|
for entry,slot in [(22418,0),(22419,2),(22416,4),(22422,5),(22417,6),(22420,7),(22423,8),(22421,9),(23059,10),(19019,15),(23043,16)]:
|
|
grant(entry,1);guid=records(entry)[0][0];equip(entry,guid,slot)
|
|
report['complete']=True;s.shot(path.with_suffix('.png'))
|
|
except Exception as error:report['error']=str(error);raise
|
|
finally:
|
|
ui.KEY_DELAY=old;report['inventory_after']=inspect()['inventory'];path.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Requested gear stage complete; evidence:',path)
|
|
if __name__=='__main__':main()
|