Initial commit: 酒桌派对 / 大话骰 multiplayer drinking-game hub

- server.py: zero-dependency stdlib backend (HTTP + WebSocket /ws), 大话骰 rule engine, server-driven bots
- live.html: real MVP frontend wired to the backend over WebSocket
- index.html/app.js/style.css: older static prototype
- deploy/: systemd unit + Nginx reverse proxy + Let's Encrypt setup.sh
- test_*.py: standalone HTTP / in-process test scripts

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gongch
2026-06-17 10:05:10 +08:00
commit 6d1dd5d56c
28 changed files with 2167 additions and 0 deletions

37
test_multi_play.py Normal file
View File

@@ -0,0 +1,37 @@
import importlib.util
spec=importlib.util.spec_from_file_location('srv','/var/minis/workspace/drinking-games-ui/server.py')
srv=importlib.util.module_from_spec(spec)
spec.loader.exec_module(srv)
room, host=srv.create_room('dice','房主','p-host')
room,p2,_=srv.join_room(room['code'],'A','p-a')
room,p3,_=srv.join_room(room['code'],'B','p-b')
room,p4,_=srv.join_room(room['code'],'C','p-c')
for pid in ['p-a','p-b','p-c']:
srv.set_ready(room['code'],pid,True)
srv.start_room(room['code'],'p-host')
room['turnIndex']=1; srv.call_dice(room['code'],'p-a',4,1,'')
room['turnIndex']=2; srv.call_dice(room['code'],'p-b',5,2,'')
room['turnIndex']=3; srv.call_dice(room['code'],'p-c',5,3,'')
room['turnIndex']=0
print('recent3', [t['playerName'] for t in srv.recent_call_targets(room,3)])
r=srv.start_multi_direct(room['code'],'p-host','open3')
print('open3', r['status'], r['lastResult']['multi'], r['lastResult']['revealDice'], r['lastResult']['text'])
room, host=srv.create_room('dice','房主','h')
room,p2,_=srv.join_room(room['code'],'A','a')
room,p3,_=srv.join_room(room['code'],'B','b')
for pid in ['a','b']:
srv.set_ready(room['code'],pid,True)
srv.start_room(room['code'],'h')
room['turnIndex']=1; srv.call_dice(room['code'],'a',3,1,'')
room['turnIndex']=2; srv.call_dice(room['code'],'b',4,2,'')
room['turnIndex']=0
srv.start_multi_direct(room['code'],'h','open2')
print('open2 pending', room['pendingAction']['type'], [t['playerName'] for t in room['pendingAction']['targets']])
srv.respond_multi(room['code'],'b','no_counter')
print('after first target idx', room['pendingAction']['currentIndex'])
srv.respond_multi(room['code'],'a','counter')
print('after counter stage', room['pendingAction']['stage'])
srv.respond_multi(room['code'],'h','decline')
print('open2 done', room['status'], room['lastResult']['text'])