forked from Sen-illion/DN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_save.py
More file actions
38 lines (31 loc) · 1.23 KB
/
load_save.py
File metadata and controls
38 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
import requests
import random
BASE = "http://127.0.0.1:5001"
# Step 1: 列出存档
print("=== 存档列表 ===")
r = requests.get(f"{BASE}/list-saves", timeout=10)
print(r.json())
# Step 2: 加载存档 (main)
print("\n=== 加载存档 'main' ===")
r = requests.post(f"{BASE}/load-game", json={"saveName": "main"}, timeout=30)
result = r.json()
print(f"status: {result.get('status')}")
if result.get("status") == "success":
gs = result.get("globalState", {})
print(f"game_id: {gs.get('game_id', 'N/A')}")
cw = gs.get("core_worldview", {})
print(f"title: {cw.get('title', 'N/A')}")
# Check what screen we're on
print(f"current_screen: {gs.get('current_screen', 'N/A')}")
# Get current options from gameplay screen
# The gameplay options are stored in the globalState
current_scene = gs.get("current_scene", "")
options = gs.get("options", [])
print(f"\ncurrent_scene: {str(current_scene)[:200]}")
print(f"options: {options}")
else:
print(f"Error: {result.get('message', 'unknown')}")