Files
drinking-game/test_one_zhai.py
gongch 6d1dd5d56c 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>
2026-06-17 10:05:10 +08:00

24 lines
1007 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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')
# 上一手飞叫1必须变斋
room['currentCall']={'count':6,'point':6,'mode':'','by':'Mia','byId':'bot'}
room['turnIndex']=0
srv.call_dice(room['code'],'p-host',7,1,'')
print('7x1 zhai', room['currentCall'])
assert room['currentCall']['mode']==''
# 平斋/切斋后重新按斋规则7个1斋后破斋要14个
room['turnIndex']=0
try:
srv.call_dice(room['code'],'p-host',13,2,'')
print('bad break accepted')
except Exception as e:
print('bad break rejected', str(e))
room['turnIndex']=0
srv.call_dice(room['code'],'p-host',14,2,'')
print('break after ping zhai ok', room['currentCall'])
assert room['currentCall']['mode']==''