-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_item_db.py
81 lines (68 loc) · 2.08 KB
/
build_item_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import json
import pyperclip
import os.path
database = "db_movvy_item.json"
def menuSystem():
selection = input(
"Select a Menu Item\n 1. Paste Items\n 2. Import Item\n 3. Print Database\n 4. Exit\n\n > "
)
if selection == "1":
export_json()
menuSystem()
elif selection == "2":
append_json()
menuSystem()
elif selection == "3":
print_json()
menuSystem()
elif selection == "4":
return
def export_json():
if not os.path.isfile(database):
data = {}
data["ItemID"] = []
for i in pyperclip.paste().split("\r\n"):
data["ItemId"].append(
{
"Id": 0,
"Item": i,
"Weight": 0,
"Class": "",
"Heals": 0,
"Durability": 0,
"Slots": "",
"Effects": "",
"Level_use": 0,
"Skill_use": "",
"Modifiers": "",
"enemy_source": "",
"location_source": "",
"holiday": "",
"Faction_craft": "",
"Level_craft": 0,
"Required_craft": "",
"Materials_craft": [{"quantity": 0, "Material": ""}],
"location_craft": "",
"quantity_craft": [{"min": 0, "max": 0}],
"skill_xp": [{"success": 0, "fail": 0}],
"char_xp": 0,
"clan_xp": 0,
"set": "",
}
)
with open(database, "w") as j:
json.dump(data, j, indent=4)
else:
print("File Already Exists")
def append_json():
with open(database, "r") as j:
data = json.load(j)
print(data)
def print_json():
with open(database, "r") as j:
data = json.load(j)
for id in data["ItemID"]:
print(f"Item: {id['Item']}")
print(f"Weight: {id['Weight']}")
print("\n")
menuSystem()