367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
73 lines
7.0 KiB
Python
73 lines
7.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Reproduce the designated disposable Warrior's normal-PvE targeted cast test.
|
|
|
|
Existing native target/cast harness owns temporary NPC/rage cleanup. This wrapper
|
|
journals GM visibility/sword setup and restores it; retains genuine defense gains.
|
|
No account permission, template, persistent spawn, grant or SQL mutation.
|
|
"""
|
|
import argparse,json,math,subprocess,sys
|
|
from pathlib import Path
|
|
from local_tortoise import db
|
|
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,require_solo_test_character,expected_gm_restore_auras,require_supported_pve_creature
|
|
from client_session import Session
|
|
import client_ui as ui
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
for n in ('character','entry','health-max'):p.add_argument('--'+n,type=int,required=True)
|
|
p.add_argument('--spell',type=int)
|
|
p.add_argument('--melee',action='store_true')
|
|
p.add_argument('--sample-seconds',type=float,default=0,help='Melee only: measured consecutive visual sampling0..8seconds; default preserves existing behavior')
|
|
p.add_argument('--combat-log',type=Path)
|
|
p.add_argument('--observe-aura',action='store_true')
|
|
p.add_argument('--observe-range',action='store_true')
|
|
p.add_argument('--output',type=Path,required=True);a=p.parse_args();out=a.output.resolve();journal=out.with_suffix('.fixture.json');log=out.with_suffix('.log')
|
|
# A fixture identity guard is not a gameplay GUID mapping. Other characters
|
|
# require their own selected-identity/source weapon contract before use.
|
|
if out.suffix!='.json' or a.character!=4509 or not 0<a.entry<65536 or not 0<a.health_max<1000000 or not out.is_relative_to(ROOT/'runtime') or any(x.exists() for x in (out,journal,log)) or not out.parent.is_dir():p.error('Require designated4509 source fixture and new runtime outputs')
|
|
if (a.melee and (a.spell is not None or not a.combat_log)) or (not a.melee and (a.spell is None or not 0<a.spell<65536)):p.error('Cast requires real spell; melee requires existing standard combat log and no spell')
|
|
if not math.isfinite(a.sample_seconds) or not 0<=a.sample_seconds<=8 or (a.sample_seconds>0 and not a.melee):p.error('Visual sampling requires melee and finite0..8seconds')
|
|
if a.combat_log and (not a.combat_log.resolve().is_relative_to(ROOT/'runtime/native-client/_classic_beta_/Logs') or not a.combat_log.is_file() or a.combat_log.is_symlink()):p.error('Require owned existing private combat log')
|
|
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;'))
|
|
state=lambda:db(f'SELECT health,power2,money,extra_flags FROM tw_char.characters WHERE guid={a.character};')
|
|
skill=lambda:db(f'SELECT value,max FROM tw_char.character_skills WHERE guid={a.character} AND skill=43;')
|
|
auras=lambda:db(f'SELECT spell FROM tw_char.character_aura WHERE guid={a.character} ORDER BY spell;')
|
|
before=state();before_skill=skill();before_auras=auras();health,rage,money,flags=map(int,before.split('\t'));value,maximum=map(int,before_skill.split('\t'))
|
|
weapon=db(f'SELECT t.class,t.subclass FROM tw_char.character_inventory ci JOIN tw_char.item_instance i ON i.guid=ci.item JOIN tw_world.item_template t ON t.entry=i.itemEntry WHERE ci.guid={a.character} AND ci.bag=0 AND ci.slot=15;')
|
|
if health!=a.health_max or rage or flags&17!=17 or weapon!='2\t7' or not 0<value<=maximum==300 or db(f'SELECT class,level FROM tw_char.characters WHERE guid={a.character};')!='1\t60':raise RuntimeError('Require reviewed full-health invisible-GM level60 Sword Warrior baseline')
|
|
require_supported_pve_creature(db(f'SELECT name,level_min,level_max,rank,npc_flags,unit_class FROM tw_world.creature_template WHERE entry={a.entry};'),60)
|
|
r=dict(pid=c.pid,character=a.character,baseline=before,skill_baseline=before_skill,aura_baseline=before_auras,pending_restoration=True,account_permissions_modified=False);journal.write_text(json.dumps(r,indent=2)+'\n');journal.chmod(0o600);old=ui.KEY_DELAY;failure=None
|
|
try:
|
|
with Session(c.pid) as s:
|
|
s.wait_world()
|
|
ui.KEY_DELAY=.03;ui.key(s.d,'F1');s.macro('/s .gm visible on');s.macro('/s .gm off');s.macro(f'/s .setskill 43 {maximum} {maximum}');s.macro('/s .save')
|
|
c.wait(lambda:int(state().split('\t')[3])==flags&~17 and skill()==f'{maximum}\t{maximum}',8)
|
|
r['test_flags']=flags&~17;journal.write_text(json.dumps(r,indent=2)+'\n')
|
|
with log.open('x') as output:
|
|
result=subprocess.run([sys.executable,str(ROOT/'ops/native_targeted_cast_test.py'),'--character',str(a.character),'--entry',str(a.entry),*(['--melee','--combat-log',str(a.combat_log)] if a.melee else ['--spell',str(a.spell)]),'--health-max',str(a.health_max),'--output',str(out),*(['--observe-aura'] if a.observe_aura else []),*(['--observe-range'] if a.observe_range else []),*(['--sample-seconds',str(a.sample_seconds)] if a.sample_seconds>0 else [])],stdout=output,stderr=subprocess.STDOUT)
|
|
r['test_exit_code']=result.returncode
|
|
if out.exists():
|
|
child=json.loads(out.read_text())
|
|
r['child_cleanup_pending']=any(child.get(k,False) for k in ('fixture_cleanup_pending','rage_restoration_pending','health_restoration_pending'))
|
|
except Exception as error:failure=type(error).__name__+': '+str(error)
|
|
finally:
|
|
try:
|
|
with Session(c.pid) as s:
|
|
s.wait_world()
|
|
ui.KEY_DELAY=.03;ui.key(s.d,'F1');s.macro('/s .gm on');s.macro('/s .gm visible off')
|
|
if flags&4:s.macro('/s .whispers on')
|
|
s.macro(f'/s .setskill 43 {value} {maximum}');s.macro('/s .save')
|
|
c.wait(lambda:state()==before and skill()==before_skill,8)
|
|
expected_auras=expected_gm_restore_auras(before_auras,flags)
|
|
if auras()!=expected_auras:raise RuntimeError('New saved aura remains; inspect source spell before controlled cleanup')
|
|
r['expected_restored_auras']=expected_auras
|
|
if expected_auras!=before_auras:r['restoration_note']='Source SetGMVisible(false) recreated legitimate GM visual16380; saved baseline was not a live aura list'
|
|
r.update(pending_restoration=False,restored_state=state(),restored_skill=skill(),restored_auras=auras(),defense_after=db(f'SELECT value,max FROM tw_char.character_skills WHERE guid={a.character} AND skill=95;'))
|
|
except Exception as error:r['restoration_error']=type(error).__name__+': '+str(error)
|
|
ui.KEY_DELAY=old
|
|
if failure:r['failure']=failure
|
|
journal.write_text(json.dumps(r,indent=2)+'\n');print(json.dumps(r))
|
|
return 0 if not failure and not r['pending_restoration'] and not r.get('child_cleanup_pending',False) and r.get('test_exit_code')==0 else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|