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'])