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:
30
test_ping_zhai.py
Normal file
30
test_ping_zhai.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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')
|
||||
for _ in range(2): srv.add_bot(room['code'],'p-host')
|
||||
srv.start_room(room['code'],'p-host')
|
||||
# 飞局:8个2飞
|
||||
room['currentCall']={'count':8,'point':2,'mode':'飞','by':'Mia','byId':'bot'}
|
||||
room['turnIndex']=0
|
||||
srv.call_dice(room['code'],'p-host',8,1,'斋')
|
||||
print('ping zhai', room['currentCall'])
|
||||
assert room['currentCall']['mode']=='斋'
|
||||
room['currentCall']={'count':8,'point':2,'mode':'飞','by':'Mia','byId':'bot'}
|
||||
room['turnIndex']=0
|
||||
srv.call_dice(room['code'],'p-host',8,3,'飞')
|
||||
print('continue fly', room['currentCall'])
|
||||
assert room['currentCall']['mode']=='飞'
|
||||
room['currentCall']={'count':8,'point':2,'mode':'飞','by':'Mia','byId':'bot'}
|
||||
room['turnIndex']=0
|
||||
try:
|
||||
srv.call_dice(room['code'],'p-host',7,1,'斋')
|
||||
print('bad accepted')
|
||||
except Exception as e:
|
||||
print('bad lower rejected', str(e))
|
||||
# 输家先叫:让房主输,下一局应房主起手
|
||||
room['status']='playing'; room['turnIndex']=1; room['currentCall']={'count':20,'point':6,'mode':'飞','by':'房主','byId':'p-host'}
|
||||
srv.open_dice(room['code'], room['players'][1]['id'])
|
||||
print('loser', room['lastResult']['loser'])
|
||||
srv.start_room(room['code'],'p-host')
|
||||
print('next starter', srv.current_player(room)['name'])
|
||||
Reference in New Issue
Block a user