"""Reviewed Friday Will v4 UI plan. No live battle-log/runtime inspection.""" from play import * import difflib,re began=json.loads((ROOT/'work/active-trainer-music.json').read_text())['start_epoch'];actor=sys.argv[1] if len(sys.argv)>1 else 'Cofagrigus';burned=actor!='Cofagrigus';screen=False;zard_tr=False def run(s,*args):subprocess.run([sys.executable,str(ROOT/'scripts'/(s+'.py')),*map(str,args)],check=True) def named(text,names): words=re.findall('[a-z-]+',text.lower()); hits=[n for n in names if any(difflib.SequenceMatcher(None,n.lower(),w).ratio()>=.78 for w in words)] assert len(hits)==1,('Ambiguous opponent',text,hits) return hits[0] for phase in range(14): rows=snap();t=' '.join(v['text'] for v in rows);low=t.lower();print('PHASE',phase,actor,t,flush=True) if re.search(r'de.?feated|for winning',low):print('WILL VICTORY',flush=True);break forced='choose a pok' in low or ('cancel' in low and low.count('hp')>=5) offered='change pok' in low or 'switch your' in low if offered: incoming=None for line in (ROOT/'recordings/screens.jsonl').read_text().splitlines()[::-1]: v=json.loads(line) if v['epoch']=5) or re.search(r'de.?feated|for winning',current),('Screen support needs review',current) else:run('battle_batch',actor,0,'--foes',foe,'--turns',1,'--watch','--stop-after-victory') else:raise SystemExit('Will plan phase limit')