import struct, sys, collections
sys.path.insert(0, r"D:\RoshEmulator\tools")
from itembase import registros
regs = [(list(struct.unpack("<39I", n)), s) for n, s in registros()]
por_id = {v[0]: (v, s) for v, s in regs}

def linha(i):
    v, s = por_id[i]
    return f"{i:7} {s[0][:26].ljust(26)} " + " ".join(f"{c}={x}" for c, x in enumerate(v) if x and c)

print("== itens conhecidos ==")
for i in (16001, 42001, 54006, 23001, 1001, 1002):
    if i in por_id: print(linha(i))

print("\n== col2 (16 valores) x exemplos de nome/modelo ==")
g = collections.defaultdict(list)
for v, s in regs: g[v[2]].append(s)
for k in sorted(g):
    ex = g[k][:3]
    print(f"  col2={k:6} n={len(g[k]):5}  " + " | ".join(f"{a[0][:18]}~{a[3][:16]}" for a in ex))

print("\n== col5 (72 valores) x exemplos ==")
g5 = collections.defaultdict(list)
for v, s in regs: g5[v[5]].append(s)
for k in sorted(g5):
    print(f"  col5={k:3} n={len(g5[k]):5}  " + " | ".join(a[0][:20] for a in g5[k][:3]))
