Add req lvl, str & dex to items.json
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
import csv
|
import csv
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
path = sys.argv[1] if len(sys.argv) >= 2 else "."
|
||||||
|
|
||||||
items = {}
|
items = {}
|
||||||
|
|
||||||
@@ -9,7 +13,7 @@ item_patches = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# build code -> names map
|
# build code -> names map
|
||||||
with open("item-names.json", encoding="utf-8-sig") as f:
|
with open(os.path.join(path, "item-names.json"), encoding="utf-8-sig") as f:
|
||||||
names = json.load(f)
|
names = json.load(f)
|
||||||
|
|
||||||
names = []
|
names = []
|
||||||
@@ -21,7 +25,7 @@ for entry in names:
|
|||||||
names[code] = {"name": name}
|
names[code] = {"name": name}
|
||||||
|
|
||||||
# Extract items
|
# Extract items
|
||||||
with open("armor.txt", newline="") as f:
|
with open(os.path.join(path, "armor.txt"), newline="") as f:
|
||||||
reader = csv.DictReader(f, delimiter="\t")
|
reader = csv.DictReader(f, delimiter="\t")
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row["name"] == "Expansion":
|
if row["name"] == "Expansion":
|
||||||
@@ -35,9 +39,12 @@ with open("armor.txt", newline="") as f:
|
|||||||
"stackable": row["stackable"] == "1",
|
"stackable": row["stackable"] == "1",
|
||||||
"width": int(row["invwidth"]),
|
"width": int(row["invwidth"]),
|
||||||
"height": int(row["invheight"]),
|
"height": int(row["invheight"]),
|
||||||
|
"req_str": int(row["reqstr"]),
|
||||||
|
"req_dex": int(row["reqdex"]),
|
||||||
|
"req_lvl": int(row["levelreq"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
with open("weapons.txt", newline="") as f:
|
with open(os.path.join(path, "weapons.txt"), newline="") as f:
|
||||||
reader = csv.DictReader(f, delimiter="\t")
|
reader = csv.DictReader(f, delimiter="\t")
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row["name"] == "Expansion":
|
if row["name"] == "Expansion":
|
||||||
@@ -53,9 +60,12 @@ with open("weapons.txt", newline="") as f:
|
|||||||
"stackable": row["stackable"] == "1",
|
"stackable": row["stackable"] == "1",
|
||||||
"width": int(row["invwidth"]),
|
"width": int(row["invwidth"]),
|
||||||
"height": int(row["invheight"]),
|
"height": int(row["invheight"]),
|
||||||
|
"req_str": 0 if len(row["reqstr"]) == 0 else int(row["reqstr"]),
|
||||||
|
"req_dex": 0 if len(row["reqdex"]) == 0 else int(row["reqdex"]),
|
||||||
|
"req_lvl": int(row["levelreq"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
with open("misc.txt", newline="") as f:
|
with open(os.path.join(path, "misc.txt"), newline="") as f:
|
||||||
reader = csv.DictReader(f, delimiter="\t")
|
reader = csv.DictReader(f, delimiter="\t")
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row["name"] == "Expansion":
|
if row["name"] == "Expansion":
|
||||||
@@ -69,10 +79,14 @@ with open("misc.txt", newline="") as f:
|
|||||||
"stackable": row["stackable"] == "1",
|
"stackable": row["stackable"] == "1",
|
||||||
"width": int(row["invwidth"]),
|
"width": int(row["invwidth"]),
|
||||||
"height": int(row["invheight"]),
|
"height": int(row["invheight"]),
|
||||||
|
"req_str": 0,
|
||||||
|
"req_dex": 0,
|
||||||
|
"req_lvl": int(row["levelreq"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
for code, patch in item_patches.items():
|
for code, patch in item_patches.items():
|
||||||
items[code].update(patch)
|
items[code].update(patch)
|
||||||
|
|
||||||
with open("items.json", "w") as f:
|
with open("items.json", "w", newline="\n") as f:
|
||||||
json.dump(items, f, indent=4)
|
json.dump(items, f, indent=4)
|
||||||
|
f.write("\n")
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user