"""DIMENSION 2 batch 11: the request URL builders and the reveal-screen readers.

HYPOTHESES
 H1 FUN_180127570 builds the DiscardCard URL and references "/%llu", so quick
    sell targets a per-item URL. FUN_180126f40 / 0x180127cc0 / 0x1801281c0 /
    0x18012a550 are the sibling builders for ByRes / Move / Apply.
 H2 One of the slot-0x160 consumers outside the deserializers reads the card's
    +0x10 field (the duplicateItemId written by the createPack post-pass) and/or
    the DiscardCard response's totalCredits at +0x28.

CONTROL: FutCreateMatchServerResponse -> 0x180120380.
"""
import traceback, os

OUT = "/tmp/claude-1000/-home-alex-Documents-OpenFUT/8e521ca1-ca3e-4138-bb96-df1744dd1d30/scratchpad/packres"

try:
    print("CONTROL FutCreateMatchServerResponse ->",
          [hex(a) for a, v, e in class_deser("FutCreateMatchServerResponse")])

    builders = [0x180126F40, 0x180127570, 0x180127CC0, 0x1801281C0, 0x18012A550,
                0x180124CA0]
    consumers = [0x180051AD0, 0x180065EB0, 0x18007C5F0, 0x18009BC40, 0x1800AF4A0,
                 0x1800E0500, 0x1800FFAA0, 0x18018AE40, 0x18018B940]
    blob = []
    for va in builders + consumers:
        s = dec(va)
        hdr = "==== %#x %s len=%d ====" % (va, fname(va), len(s))
        print(hdr)
        print(s)
        blob.append(hdr + "\n" + s)
    with open(os.path.join(OUT, "d2_builders_consumers.txt"), "w") as f:
        f.write("\n".join(blob))
except Exception:
    traceback.print_exc()
