Add prototype gameplay loop with character/battlefield assets and server game APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Prepare only the isolated inventory UI account; never touch the real development DB."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
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()
|
||||
mode = sys.argv[1] if len(sys.argv) == 2 else ''
|
||||
if test_root not in database.parents or not username.startswith('g1live_inventory_') or mode not in ('coins', 'decor', 'poor', 'reset'):
|
||||
raise RuntimeError('Refusing non-isolated inventory 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()
|
||||
state = json.loads(row[1])
|
||||
if state['schema'] not in (6, 7, 8) or state.get('pendingShot') or state.get('pendingBattle'):
|
||||
raise RuntimeError('Finish isolated pending activities first')
|
||||
if mode == 'coins':
|
||||
state.update(coins=1000, cleared=True, clearedStages=[1, 1, 1, 0, 0])
|
||||
state['shards'][0] = 40
|
||||
elif mode == 'decor':
|
||||
state.update(clearedStages=[1, 1, 1, 1, 1], decorations=[1, 0, 0], campLayout=[-1, -1, -1])
|
||||
elif mode == 'poor':
|
||||
state['coins'] = 99
|
||||
state['shopBought'][1] = 0
|
||||
else:
|
||||
state['dailyDay'] -= 1
|
||||
state['revision'] += 1
|
||||
conn.execute('UPDATE game_states SET state=? WHERE pid=?', (json.dumps(state, ensure_ascii=False), row[0]))
|
||||
print('Prepared isolated inventory UI boundary:', mode)
|
||||
Reference in New Issue
Block a user