30 lines
881 B
Python
30 lines
881 B
Python
import httpx, json, time
|
|
|
|
c = httpx.Client()
|
|
base = 'http://localhost:8000'
|
|
|
|
g = c.post(base + '/api/games/create', json={'script_id': 'script_fog', 'human_role_id': 'role_detective'}).json()
|
|
gid = g['game_id']
|
|
print('Game:', gid[:8])
|
|
|
|
s = c.get(base + f'/api/games/{gid}/state').json()
|
|
for p in s['players']:
|
|
print(f' {p["role_name"]} (human={p["is_human"]})')
|
|
|
|
c.post(base + f'/api/games/{gid}/start')
|
|
print('Started')
|
|
|
|
ch = c.post(base + f'/api/games/{gid}/chat', json={
|
|
'sender_role_id': 'role_detective', 'type': 'public', 'content': '各位,案发时你们在哪?'
|
|
}).json()
|
|
print('Chat sent:', ch['status'])
|
|
|
|
time.sleep(1.5)
|
|
|
|
s2 = c.get(base + f'/api/games/{gid}/state').json()
|
|
print(f'\nMessages ({len(s2["messages"])}):')
|
|
for m in s2['messages'][-6:]:
|
|
print(f' [{m["sender_name"]}] {m["content"][:60]}')
|
|
|
|
print('\n=== NPC auto-response test passed ===')
|