예제 #1
0
def dispatch_blob(blob):
    seq = blob.get("block_title_sequence", -1)
    log_line = blob.get("log_line", -1)
    if seq:
        app.mtga_app.mtga_logger.debug(
            "{}dispatching seq ({}) / log_line {}".format(
                util.ld(), seq, log_line))
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "Deck.GetDeckLists" in blob:  # this looks like it's a response to a jsonrpc method
        parsers.parse_get_decklists(blob)
    elif "block_title" in blob and (blob["block_title"] == "Event.DeckSubmit"
                                    or blob["block_title"]
                                    == "Event.GetPlayerCourse"):
        parsers.parse_event_decksubmit(blob)
    elif "block_title" in blob and blob[
            "block_title"] == "PlayerInventory.GetPlayerCardsV3":
        parsers.parse_get_player_cards_v3(blob)
    elif "block_title" in blob and (blob["block_title"] == "Draft.DraftStatus"
                                    or blob["block_title"]
                                    == "Draft.MakePick"):
        parsers.parse_draft_status(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gametoom_state_change(blob)
예제 #2
0
def dispatch_blob(blob):
    seq = blob.get("block_title_sequence", -1)
    log_line = blob.get("log_line", -1)
    if seq:
        app.mtga_app.mtga_logger.debug("{}dispatching seq ({}) / log_line {}".format(util.ld(), seq, log_line))
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "Deck.GetDeckLists" in blob:  # this looks like it's a response to a jsonrpc method
        parsers.parse_get_decklists(blob)
    elif "block_title" in blob and (blob["block_title"] == "Event.DeckSubmit" or
                                    blob["block_title"] == "Event.GetPlayerCourse"):
        parsers.parse_event_decksubmit(blob)
    elif "block_title" in blob and blob["block_title"] == "PlayerInventory.GetPlayerCardsV3":
        parsers.parse_get_player_cards_v3(blob)
    elif "block_title" in blob and (blob["block_title"] == "Draft.DraftStatus" or
                                    blob["block_title"] == "Draft.MakePick"):
        parsers.parse_draft_status(blob)
    # PlayerInventory.GetPlayerInventory
    elif "block_title" in blob and blob["block_title"] == "PlayerInventory.GetPlayerInventory":
        parsers.pass_through("inventory", blob["playerId"], blob)
    elif "block_title" in blob and blob["block_title"] == "Rank.Updated":
        parsers.pass_through("rank_change", blob["playerId"], blob)
    elif "block_title" in blob and blob["block_title"] == "Inventory.Updated":
        parsers.pass_through("inventory_update", None, blob)
    elif ("block_title" in blob and blob["block_title"] == "ClientToMatchServiceMessageType_ClientToGREMessage" and
          "Payload" in blob and "SubmitDeckResp" in blob['Payload']):
        parsers.parse_sideboard_submit(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gametoom_state_change(blob)
    elif "block_title" in blob and blob["block_title"] == "Event.MatchCreated":
        parsers.parse_match_created(blob)
예제 #3
0
def dispatch_blob(blob):
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "Deck.GetDeckLists" in blob:  # this looks like it's a response to a jsonrpc method
        parsers.parse_get_decklists(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gametoom_state_change(blob)
예제 #4
0
def dispatch_blob(blob):
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "Deck.GetDeckLists" in blob:  # this looks like it's a response to a jsonrpc method
        parsers.parse_get_decklists(blob)
    elif "block_title" in blob and (blob["block_title"] == "Event.DeckSubmit" or \
                                    blob["block_title"] == "Event.GetPlayerCourse"):
        parsers.parse_event_decksubmit(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gametoom_state_change(blob)
예제 #5
0
def dispatch_blob(blob):
    seq = blob.get("block_title_sequence", -1)
    log_line = blob.get("log_line", -1)
    if seq:
        app.mtga_app.mtga_logger.debug("{}dispatching seq ({}) / log_line {}".format(util.ld(), seq, log_line))
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "block_title" in blob and blob["block_title"] == "Deck.GetDeckListsV3":
        parsers.parse_get_decklists(blob, version=3)
    elif "block_title" in blob and blob["block_title"] == "Deck.UpdateDeckV3":
        parsers.parse_update_deck_v3(blob)
    elif "block_title" in blob and (blob["block_title"] == "Event.DeckSubmit" or
                                    blob["block_title"] == "Event.GetPlayerCourse"):
        parsers.parse_event_decksubmit(blob)
    elif "block_title" in blob and blob["block_title"] == "Event.DeckSubmitV3":
        parsers.parse_event_decksubmit(blob, version=3)
    elif "block_title" in blob and blob["block_title"] == "Event.GetPlayerCourseV2":
        parsers.parse_event_decksubmit(blob, version=3)
    # TODO: is GetPlayerCoursesV2 useful?
    # elif "block_title" in blob and blob["block_title"] == "Event.GetPlayerCoursesV2":
    #     parsers.parse_player_courses_v2(blob)
    elif "block_title" in blob and blob["block_title"] == "PlayerInventory.GetPlayerCardsV3":
        parsers.parse_get_player_cards_v3(blob["payload"])
    elif "block_title" in blob and (blob["block_title"] == "Draft.DraftStatus" or
                                    blob["block_title"] == "Draft.MakePick"):
        parsers.parse_draft_status(blob)
    elif "block_title" in blob and blob["block_title"] == "PlayerInventory.GetPlayerInventory":
        parsers.pass_through("inventory", blob["payload"]["playerId"], blob["payload"])
    elif "block_title" in blob and blob["block_title"] == "Rank.Updated":
        parsers.pass_through("rank_change", blob["playerId"], blob)
    elif "block_title" in blob and blob["block_title"] == "Inventory.Updated":
        parsers.pass_through("inventory_update", None, blob)
    elif ("block_title" in blob and blob["block_title"] == "ClientToMatchServiceMessageType_ClientToGREMessage" and
          "Payload" in blob and "SubmitDeckResp" in blob['Payload']):
        parsers.parse_sideboard_submit(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gameroom_state_change(blob)
    elif "block_title" in blob and blob["block_title"] == "Event.MatchCreated":
        parsers.parse_match_created(blob)

    # parse on hover event to check what we are looking at, at this moment
    elif "block_title" in blob and blob["block_title"] == "ClientToMatchServiceMessageType_ClientToGREUIMessage":
        parsers.parse_hover(blob)
예제 #6
0
def dispatch_blob(blob):
    seq = blob.get("block_title_sequence", -1)
    if seq:
        app.mtga_app.mtga_logger.debug("{}dispatching seq ({})".format(
            util.ld(), seq))
    if "method" in blob and "jsonrpc" in blob:
        dispatch_jsonrpc_method(blob)
    elif "greToClientEvent" in blob:
        dispatch_gre_to_client(blob)
    elif "clientToGreMessage" in blob:
        dispatch_client_to_gre(blob)
    elif "Deck.GetDeckLists" in blob:  # this looks like it's a response to a jsonrpc method
        parsers.parse_get_decklists(blob)
    elif "block_title" in blob and (blob["block_title"] == "Event.DeckSubmit" or \
                                    blob["block_title"] == "Event.GetPlayerCourse"):
        parsers.parse_event_decksubmit(blob)
    elif "matchGameRoomStateChangedEvent" in blob:
        dispatch_match_gametoom_state_change(blob)
예제 #7
0
def watch_for_cards(in_queue, out_queue):
    last_blob = None
    while all_done_q.empty():
        json_recieved = in_queue.get()
        if json_recieved is None:
            out_queue.put(None)
            break

        if last_blob == json_recieved:
            continue  # don't double fire
        if "Deck.GetDeckLists" in json_recieved:  # this looks like it's a response to a jsonrpc method
            decks = parsers.parse_get_decklists(json_recieved)
            print(json_recieved)
            for deck in decks:
                if deck.pool_name == "Imported Deck":
                    log_deck_result_queue.put(deck.cards)
    print("watch_for_cards task finished")