-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwakutils.py
116 lines (77 loc) · 3.9 KB
/
wakutils.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This Python file uses the following encoding: utf-8
import os
import json
import settings
import tempfile
def parse():
current_dir = os.path.dirname(os.path.abspath(__file__))
itemPropertiesFile = open(os.path.join(current_dir,"data/1.78.1.7/itemProperties.json"), encoding="utf-8")
itemPropertiesData = json.load(itemPropertiesFile)
itemsFile = open(os.path.join(current_dir,"data/1.78.1.7/items.json"), encoding="utf-8")
itemsData = json.load(itemsFile)
equipmentItemTypesFile = open(os.path.join(current_dir,"data/1.78.1.7/equipmentItemTypes.json"), encoding="utf-8")
equipmentItemTypesData = json.load(equipmentItemTypesFile)
actionFile = open(os.path.join(current_dir,"data/1.78.1.7/actions.json"), encoding="utf-8")
actionData = json.load(actionFile)
settings.ITEMS_DATA=itemsData
settings.EQUIPMENT_ITEM_TYPES_DATA=equipmentItemTypesData
settings.ITEM_PROPERTIES_DATA=itemPropertiesData
settings.ACTION_DATA=actionData
def restruct_item_into_id_map():
resDict={}
for item in settings.ITEMS_DATA:
equipEffectsDict={}
for equipEffect in item['definition']['equipEffects']:
equipEffectsDict[equipEffect['effect']['definition']['actionId']]=equipEffect
item['definition']['equipEffects']=equipEffectsDict
resDict[item['definition']['item']['id']]=item
settings.ITEMS_DATA=resDict
resDict = {}
for item in settings.EQUIPMENT_ITEM_TYPES_DATA:
resDict[item['definition']['id']]=item
settings.EQUIPMENT_ITEM_TYPES_DATA=resDict
resDict = {}
for action in settings.ACTION_DATA:
resDict[action['definition']['id']]=action
settings.ACTION_DATA=resDict
def isPrimaryWeapon(item):
try:
equipmentType = settings.EQUIPMENT_ITEM_TYPES_DATA[settings.EQUIPMENT_ITEM_TYPES_DATA[item['definition']['item']['baseParameters']['itemTypeId']]['definition']['parentId']]
return 'FIRST_WEAPON' in equipmentType['definition']['equipmentPositions'] and not 'SECOND_WEAPON' in equipmentType['definition']['equipmentDisabledPositions']
#non weapon item have parent id 118 which does not exist
except KeyError:
return False
def isSecondaryWeapon(item):
try:
equipmentType = settings.EQUIPMENT_ITEM_TYPES_DATA[settings.EQUIPMENT_ITEM_TYPES_DATA[item['definition']['item']['baseParameters']['itemTypeId']]['definition']['parentId']]
if 'SECOND_WEAPON' in equipmentType['definition']['equipmentPositions']:
return True
#non weapon item have parent id 118 which does not exist
except KeyError:
return False
def isTwoHanded(item):
try:
equipmentType = settings.EQUIPMENT_ITEM_TYPES_DATA[settings.EQUIPMENT_ITEM_TYPES_DATA[item['definition']['item']['baseParameters']['itemTypeId']]['definition']['parentId']]
if 'FIRST_WEAPON' in equipmentType['definition']['equipmentPositions'] and 'SECOND_WEAPON' in equipmentType['definition']['equipmentDisabledPositions']:
return True
return False
#non weapon item have parent id 118 which does not exist
except KeyError:
return False
def add_direct_weapon_type():
for key,item in settings.ITEMS_DATA.items():
if isPrimaryWeapon(item):
settings.ITEMS_DATA[key]['definition']['item']['baseParameters']['isPrimary'] = 1
if isSecondaryWeapon(item):
settings.ITEMS_DATA[key]['definition']['item']['baseParameters']['isSecondary'] = 1
if isTwoHanded(item):
settings.ITEMS_DATA[key]['definition']['item']['baseParameters']['isTwoHanded'] = 1
def setupJson():
parse()
restruct_item_into_id_map()
add_direct_weapon_type()
json_object= json.dumps(settings.ITEMS_DATA,indent=4)
with tempfile.NamedTemporaryFile(mode="w", delete=False) as outfile:
outfile.write(json_object)
print(outfile.name)
# find a place to put the tempory files | outfile.name to get path