forked from omicron/d2warehouse
Add prefix/suffix extraction
This commit is contained in:
39
contrib/affixes.py
Normal file
39
contrib/affixes.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import csv
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
path = sys.argv[1] if len(sys.argv) >= 2 else "."
|
||||||
|
|
||||||
|
category = "Base"
|
||||||
|
affixes = {"prefixes": {}, "suffixes": {}}
|
||||||
|
with open(os.path.join(path, "magicprefix.txt")) as f:
|
||||||
|
dr = csv.DictReader(f, delimiter="\t")
|
||||||
|
index = 0
|
||||||
|
for row in dr:
|
||||||
|
index += 1
|
||||||
|
if len(row["Name"]) == 0:
|
||||||
|
continue
|
||||||
|
affixes["prefixes"][index] = {
|
||||||
|
"name": row["Name"],
|
||||||
|
"req_lvl": row["levelreq"],
|
||||||
|
"req_class": None if len(row["class"]) == 0 else row["class"],
|
||||||
|
}
|
||||||
|
|
||||||
|
with open(os.path.join(path, "magicsuffix.txt")) as f:
|
||||||
|
dr = csv.DictReader(f, delimiter="\t")
|
||||||
|
index = 0
|
||||||
|
for row in dr:
|
||||||
|
index += 1
|
||||||
|
if len(row["Name"]) == 0:
|
||||||
|
continue
|
||||||
|
affixes["suffixes"][index] = {
|
||||||
|
"name": row["Name"],
|
||||||
|
"req_lvl": row["levelreq"],
|
||||||
|
"req_class": None if len(row["class"]) == 0 else row["class"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
with open("affixes.json", "w", newline="\n") as f:
|
||||||
|
json.dump(affixes, f, indent=4)
|
||||||
|
f.write("\n")
|
||||||
6906
d2warehouse/data/affixes.json
Normal file
6906
d2warehouse/data/affixes.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user