"""Prepare only the isolated UI-test account at a deterministic pity boundary.""" import json from pathlib import Path import sqlite3 root = Path(__file__).resolve().parents[1] test_root = (root / 'Tools/output/g1-live').resolve() database = Path((test_root / 'db.path').read_text(encoding='utf-8-sig').strip()).resolve() username = (test_root / 'account.txt').read_text(encoding='utf-8-sig').strip() if test_root not in database.parents or not username.startswith('g1live_'): raise RuntimeError('Refusing to edit a database/account outside the isolated live fixture') with sqlite3.connect(database) as conn: row = conn.execute('SELECT u.pid,g.state FROM users u JOIN game_states g ON g.pid=u.pid WHERE u.username=?', (username,)).fetchone() if row is None: raise RuntimeError('Isolated account has no game state') state = json.loads(row[1]) if state['schema'] not in (3, 4, 5, 6, 7, 8) or state.get('pendingShot') or state.get('pendingBattle'): raise RuntimeError('Finish pending test activities before preparing capture fixture') state.update(tickets=10, stages=[1, 1, 1, 1, 0], captureTutorialDone=True, captureCount=4, duplicateStreak=4) state['shards'][0] = 80 state['revision'] += 1 conn.execute('UPDATE game_states SET state=? WHERE pid=?', (json.dumps(state, ensure_ascii=False), row[0])) print('Prepared isolated capture fixture: four duplicates, only water partner missing, ten tickets')