def UserLogin(self, request, context): try: res = game_engine.login_user(request) if res: return ActionResponse(code=0, info="login user success") else: return ActionResponse( code=-1, info="login user failed:\nWrong user or password") except: return ActionResponse(code=-1, info="login user failed:\n{}".format( traceback.format_exc()))
def CreateRoom(self, request, context): try: res = game_engine.login_user(request.user_info) if not res: return RoomResponse( code=-1, info="login user failed:\nWrong user or password") room_id = game_engine.create_room(request.room_name, request.blind, request.buyin) return game_engine.rooms[room_id].GetRoomInfo() except: return RoomResponse(code=-1, info="create room failed:\n{}".format( traceback.format_exc()))
def Action(self, request, context): try: res = game_engine.login_user(request.user_info) if not res: return ActionResponse( code=-1, info="login user failed:\nWrong user or password") game_engine.rooms[request.room_id].queue.put( (request.user_info.user_name, json.loads(request.extra))) return ActionResponse(code=0, info="action recieved success.") except: return ActionResponse(code=-1, info="action recieved failed:\n{}".format( traceback.format_exc()))
def GetStatus(self, request, context): try: res = game_engine.login_user(request.user_info) if not res: return GetStatusResponse( code=-1, info="get status failed:\nWrong user or password") return GetStatusResponse( code=0, info="get status success", room_status=game_engine.rooms[request.room_id].GetStatus( request.user_info.user_name)) except: return GetStatusResponse(code=-1, info="get status failed:\n{}".format( traceback.format_exc()))