367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
71 lines
6.7 KiB
Python
71 lines
6.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual normal self-form cast, with explicit legitimate local fixture setup.
|
|
|
|
Only a real zero-cost shapeshift spell from the local source is accepted. GM
|
|
learning/removal prepares the fixture; only original /cast tests execution.
|
|
Failure restoration via GM aura is labelled separately and never counted as a
|
|
successful cast. No SQL write, raw request injection or retry is performed.
|
|
"""
|
|
import argparse,json,re
|
|
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_authenticated_turtle_realm,require_native_gameplay_policy,require_solo_test_character
|
|
from native_world_trace import WorldTrace
|
|
from native_vendor_buy_test import inventory
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
for name in ('character','spell','form'):p.add_argument('--'+name,type=int,required=True)
|
|
p.add_argument('--learn-missing-fixture',action='store_true',help='Explicitly permit genuine local GM learning if source spell absent')
|
|
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 out.parent.is_dir() or not 0<a.character<2**32 or not 0<a.spell<2**16 or not 0<a.form<256:p.error('Require bounded reviewed source identity and new runtime report')
|
|
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'));require_solo_test_character(a.character,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
|
|
definition=db(f'SELECT name,manaCost,effect1,effectApplyAuraName1,effectMiscValue1 FROM tw_world.spell_template WHERE entry={a.spell};').split('\t')
|
|
if len(definition)!=5 or definition[1:]!=['0','6','36',str(a.form)] or not re.fullmatch(r'[A-Za-z -]{1,100}',definition[0]):raise RuntimeError('Source is not the reviewed zero-cost self-form fixture')
|
|
spell=lambda:db(f'SELECT active,disabled FROM tw_char.character_spell WHERE guid={a.character} AND spell={a.spell};')
|
|
aura=lambda:db(f'SELECT COUNT(*) FROM tw_char.character_aura WHERE guid={a.character} AND spell={a.spell};')
|
|
state=lambda:db(f'SELECT level,health,money,extra_flags FROM tw_char.characters WHERE guid={a.character};')
|
|
before_spell=spell();baseline=inventory(a.character);before_state=state()
|
|
source_default=db(f'SELECT p.spell FROM tw_world.playercreateinfo_spell p JOIN tw_char.characters c ON c.race=p.race AND c.class=p.class WHERE c.guid={a.character} AND p.spell={a.spell};')==str(a.spell)
|
|
if before_spell not in ('','1\t0') or (not before_spell and not source_default and not a.learn_missing_fixture) or int(aura())<1:raise RuntimeError('Require saved source form aura and explicitly authorized learned baseline')
|
|
report=dict(pid=c.pid,external_gateway_running=False,spell=a.spell,form=a.form,source_definition=definition,source_default_spell=source_default,before_spell=before_spell,before_state=before_state,cast_attempted=False,cast_pipeline_verified=False,fixture_restore_pending=False,ui_review_required=True);failure=None;old=ui.KEY_DELAY
|
|
with WorldTrace(c) as trace:
|
|
try:
|
|
with Session(c.pid) as s:
|
|
if s.state()!='world':raise RuntimeError('Require actual original native world')
|
|
ui.KEY_DELAY=.03;ui.key(s.d,'F1')
|
|
if not before_spell and not source_default:
|
|
report['gm_learn_fixture']=True;s.macro(f'/s .learn {a.spell}');report['source_learn']=trace.wait(1,0x12b,5)
|
|
s.macro('/s .save');c.wait(lambda:spell()=='1\t0',8)
|
|
report['fixture_restore_pending']=True;s.macro(f'/s .unaura {a.spell}');s.macro('/s .save');c.wait(lambda:int(aura())==0,8)
|
|
s.macro('/run print("GW form prepared",GetShapeshiftForm(),GetShapeshiftFormID())');s.shot(out.with_name(out.stem+'-prepared.png'))
|
|
report['cast_attempted']=True;s.macro('/cast '+definition[0]);report['native_request']=trace.wait(2,0x3e0176,5)
|
|
index=report['native_request']['index'];report['native_start']=trace.wait(3,0x69002d,5,after_index=index)
|
|
report['source_start']=trace.source_before(report['native_start'],0x131,after_index=index)
|
|
report['native_go']=trace.wait(3,0x69002c,5,after_index=index);report['source_go']=trace.source_before(report['native_go'],0x132,after_index=index)
|
|
s.macro('/s .save');c.wait(lambda:int(aura())>0,8)
|
|
report['fixture_restore_pending']=False
|
|
s.macro('/run print("GW cast form result",GetShapeshiftForm(),GetShapeshiftFormID(),UnitHealth("player"),GetMoney())');s.shot(out.with_suffix('.png'))
|
|
pipe=c.rpc('inspect-engine-pipe');report.update(request=pipe['spell_request'],pipe_error=pipe['error'],pipe_closed=pipe['closed'],saved_spell=spell(),saved_form_auras=aura(),after_state=state(),inventory_unchanged=inventory(a.character)==baseline)
|
|
if state()!=before_state or not report['inventory_unchanged'] or pipe['spell_request']['result']:raise RuntimeError('Source state/inventory/cast encoding differed')
|
|
report['cast_pipeline_verified']=not pipe['error'] and not pipe['closed']
|
|
except Exception as error:failure=type(error).__name__+': '+str(error)
|
|
finally:
|
|
try:
|
|
if report['fixture_restore_pending']:
|
|
with Session(c.pid) as s:
|
|
if s.state()!='world':raise RuntimeError('World unavailable; source form restoration pending')
|
|
ui.KEY_DELAY=.03;s.macro(f'/s .aura {a.spell}');s.macro('/s .save');c.wait(lambda:int(aura())>0,8)
|
|
report.update(fixture_restore_pending=False,gm_failure_restoration=True)
|
|
except Exception as error:report['fixture_restoration_error']=type(error).__name__+': '+str(error)
|
|
ui.KEY_DELAY=old
|
|
report.update(trace.report())
|
|
if failure:report['failure']=failure
|
|
out.write_text(json.dumps(report,indent=2)+'\n');out.chmod(0o600)
|
|
print(json.dumps({k:report.get(k) for k in ('pid','source_learn','native_request','source_start','source_go','native_go','cast_pipeline_verified','saved_spell','saved_form_auras','inventory_unchanged','lost_metadata_rows','observer_error','fixture_restore_pending','gm_failure_restoration','failure','fixture_restoration_error')}))
|
|
return 0 if report['cast_pipeline_verified'] and not trace.error and not report['fixture_restore_pending'] else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|