Files
my-botty/scripts/make_stash_csv.py
T
alexpolo1andClaude Sonnet 4.6 cbc797c14a Stash scanner: fix multi-slot dedup, add periodic bot hook + trade CSV
- scripts/stash_inventory.py: fix BaseItem["dimensions"] being a list
  not a dict — use dims[0] for height so the claimed-slot dedup works
  and multi-slot items (Large/Grand Charms, 2h weapons) are no longer
  double-counted
- scripts/make_stash_csv.py: new — convert stash_inventory.json to a
  deduplicated stash_list.csv (name, page, stats) for trade reference
- stash_list.csv: current stash export (71 unique items)
- config/params.ini: add stash_scan_interval (default 0/off)
- src/config.py: parse stash_scan_interval from [general]
- src/bot.py: after stash+transmute, trigger scan every N runs when
  stash_scan_interval > 0
- src/inventory/personal.py: reset transfer_failures per stash tab so
  each tab gets its own 2-failure budget before moving to the next
- tools/testbed.py: PASS/FAIL fix for `stash all` — equipped-area cols
  (≥4) correctly left in inventory is a PASS not a FAIL (Bug 19 guard)
- CLAUDE.md: document stash scanner scripts in File Quick Reference

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-06-16 20:40:05 +02:00

64 lines
1.9 KiB
Python

"""Generate a deduplicated trade CSV from the stash scan JSON."""
import json, csv, os, sys
_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PAGE_LABELS = {
0: "personal",
1: "shared_1",
2: "shared_2_uniques_sets",
3: "shared_3",
4: "shared_4",
5: "shared_5",
}
SKIP_LINES = {
"KEEP IN INVENTORY TO GAIN BONUS",
"INSERT SCROLLS",
"RIGHT CLICK TO USE",
}
def make_csv(json_path, out_path):
data = json.load(open(json_path, encoding="utf-8"))
seen = {} # name -> row dict, first occurrence wins
order = []
for page_str, items in sorted(data.items(), key=lambda x: int(x[0])):
page = int(page_str)
seen_pos = set()
for item in items:
name = item["name"]
pos = (item["col"], item["row"])
if pos in seen_pos or not name or name.startswith("("):
continue
seen_pos.add(pos)
if name in seen:
continue
stats_lines = [
ln for ln in item["full_text"].splitlines()
if ln and ln != name and ln not in SKIP_LINES
]
row = {
"name": name,
"page": PAGE_LABELS.get(page, f"shared_{page}"),
"stats": " | ".join(stats_lines),
}
seen[name] = row
order.append(name)
with open(out_path, "w", newline="", encoding="utf-8") as f:
w = csv.DictWriter(f, fieldnames=["name", "page", "stats"])
w.writeheader()
for name in order:
w.writerow(seen[name])
return order, seen
if __name__ == "__main__":
json_in = os.path.join(_root, "log", "stash_inventory.json")
csv_out = os.path.join(_root, "stash_list.csv")
order, seen = make_csv(json_in, csv_out)
print(f"Written {len(order)} unique items -> {csv_out}")
for name in order:
print(f" [{seen[name]['page']}] {name}")