def dispatch_gre_to_client(blob): client_messages = blob["greToClientEvent"]['greToClientMessages'] dont_care_types = ["GREMessageType_UIMessage"] for message in client_messages: message_type = message["type"] if message_type in dont_care_types: pass elif message_type in ["GREMessageType_GameStateMessage", "GREMessageType_QueuedGameStateMessage"]: game_state_message = message['gameStateMessage'] try: parsers.parse_game_state_message(game_state_message, blob["timestamp"] if "timestamp" in blob.keys() else None) except: import traceback exc = traceback.format_exc() stack = traceback.format_stack() app.mtga_app.mtga_logger.error("{}Exception @ count {}".format(util.ld(True), app.mtga_app.mtga_watch_app.error_count)) app.mtga_app.mtga_logger.error(exc) app.mtga_app.mtga_logger.error(stack) app.mtga_app.mtga_watch_app.send_error("Exception during parse game state. Check log for more details") elif message_type == "GREMessageType_MulliganReq": try: parsers.parse_mulligan_req_message(message, blob["timestamp"] if "timestamp" in blob.keys() else None) except: import traceback exc = traceback.format_exc() stack = traceback.format_stack() app.mtga_app.mtga_logger.error( "{}Exception @ count {}".format(util.ld(True), app.mtga_app.mtga_watch_app.error_count)) app.mtga_app.mtga_logger.error(exc) app.mtga_app.mtga_logger.error(stack) app.mtga_app.mtga_watch_app.send_error("Exception during parse game state. Check log for more details")
def dispatch_gre_to_client(blob): client_messages = blob["greToClientEvent"]['greToClientMessages'] dont_care_types = ["GREMessageType_UIMessage"] for message in client_messages: message_type = message["type"] if message_type in dont_care_types: pass elif message_type in ["GREMessageType_GameStateMessage", "GREMessageType_QueuedGameStateMessage"]: game_state_message = message['gameStateMessage'] parsers.parse_game_state_message(game_state_message)
def dispatch_gre_to_client(blob): client_messages = blob["greToClientEvent"]['greToClientMessages'] dont_care_types = ["GREMessageType_UIMessage"] action_required_types = ["GREMessageType_PayCostsReq", "GREMessageType_ActionsAvailableReq", "GREMessageType_DeclareAttackersReq", "GREMessageType_DeclareBlockersReq", "GREMessageType_SelectNReq"] prompt_action_required_types = ["GREMessageType_PromptReq"] doing_action = False for message in client_messages: message_type = message["type"] if message_type in dont_care_types: pass elif message_type in action_required_types: doing_action = True parsers.parse_action_required_message(message) elif message_type in prompt_action_required_types: doing_action = True parsers.parse_prompt_action_required(message) elif message_type in ["GREMessageType_GameStateMessage", "GREMessageType_QueuedGameStateMessage"]: game_state_message = message['gameStateMessage'] try: parsers.parse_game_state_message(game_state_message, blob["timestamp"] if "timestamp" in blob.keys() else None) except: import traceback exc = traceback.format_exc() stack = traceback.format_stack() app.mtga_app.mtga_logger.error( "{}Exception @ count {}".format(util.ld(True), app.mtga_app.mtga_watch_app.error_count)) app.mtga_app.mtga_logger.error(exc) app.mtga_app.mtga_logger.error(stack) app.mtga_app.mtga_watch_app.send_error("Exception during parse game state. Check log for more details") elif message_type == "GREMessageType_MulliganReq": try: parsers.parse_mulligan_req_message(message, blob["timestamp"] if "timestamp" in blob.keys() else None) except: import traceback exc = traceback.format_exc() stack = traceback.format_stack() app.mtga_app.mtga_logger.error( "{}Exception @ count {}".format(util.ld(True), app.mtga_app.mtga_watch_app.error_count)) app.mtga_app.mtga_logger.error(exc) app.mtga_app.mtga_logger.error(stack) app.mtga_app.mtga_watch_app.send_error("Exception during parse game state. Check log for more details")