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:
35
test_challenge.py
Normal file
35
test_challenge.py
Normal file
@@ -0,0 +1,35 @@
|
||||
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)
|
||||
|
||||
def setup():
|
||||
room, host=srv.create_room('dice','房主','p-host')
|
||||
room,p2,_=srv.join_room(room['code'],'客人','p-guest')
|
||||
srv.set_ready(room['code'],'p-guest',True)
|
||||
srv.start_room(room['code'],'p-host')
|
||||
srv.call_dice(room['code'],'p-host',2,1,'斋')
|
||||
return room
|
||||
|
||||
# 普通开骰 -> 反劈 -> 不受
|
||||
room=setup(); code=room['code']
|
||||
srv.open_dice(code,'p-guest')
|
||||
print('open pending', room['pendingAction']['stage'])
|
||||
srv.respond_challenge(code,'p-host','counter')
|
||||
print('counter pending', room['pendingAction']['stage'])
|
||||
srv.respond_challenge(code,'p-guest','decline')
|
||||
print('open counter decline result', room['status'], room['lastResult']['loser'], room['lastResult']['cups'], room['lastResult']['revealDice'])
|
||||
|
||||
# 劈 -> 不受
|
||||
room=setup(); code=room['code']
|
||||
srv.split_dice(code,'p-guest')
|
||||
print('split pending', room['pendingAction']['stage'])
|
||||
srv.respond_challenge(code,'p-host','decline')
|
||||
print('split decline result', room['status'], room['lastResult']['loser'], room['lastResult']['cups'], room['lastResult']['revealDice'])
|
||||
|
||||
# 劈 -> 反劈 -> 受
|
||||
room=setup(); code=room['code']
|
||||
srv.split_dice(code,'p-guest')
|
||||
srv.respond_challenge(code,'p-host','counter')
|
||||
print('split counter pending', room['pendingAction']['stage'])
|
||||
srv.respond_challenge(code,'p-guest','accept')
|
||||
print('split counter accept result', room['status'], room['lastResult']['cups'], room['lastResult']['revealDice'])
|
||||
Reference in New Issue
Block a user