-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrary.py
129 lines (116 loc) · 4.21 KB
/
library.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Sub-modules
def jsonWrapper(x,y,item):
'''Wrap item line in json format
'''
line = ' {\n'+\
' "x": '+str(x)+',\n' + \
' "y": '+str(y)+',\n' + \
' "marker": "FixedLoot",\n' +\
' "width": 1,\n'+\
' "height": 1,\n'+\
' "item": "'+item+'"\n' + \
' },\n'
return (line)
def xmlWrapper(id, x,y,item):
'''Wrap item line in xml format
'''
line = '<object id="'+ str(id)+'" name="Timo" type="FixedLoot" x="'+str(x*24)+'" y="'+str(y*24)+'" width="24" height="24">\n'
line +=' <properties>\n'
line +=' <property name="item" value="'+str(item)+'"/>\n'
line +=' </properties>\n'
line +=' </object>\n'
return (line)
def jsonWrapperLoot(x,y,item):
'''Wrap item line in json format
'''
line = ' {\n'+\
' "x": '+str(x)+',\n' + \
' "y": '+str(y)+',\n' + \
' "marker": "FixedLoot",\n' +\
' "width": 1,\n'+\
' "height": 1,\n'+\
' "item": "'+item+'"\n' + \
' },\n'
return (line)
def xmlWrapperBP(id, x,y,item):
'''Wrap item line in xml format for blueprint items
'''
line = '<object id="'+ str(id)+'" name="Timo" type="FixedBlueprint" x="'+str(x*24)+'" y="'+str(y*24)+'" width="24" height="24">\n'
line +=' <properties>\n'
line +=' <property name="item" value="'+str(item)+'"/>\n'
line +=' </properties>\n'
line +=' </object>\n'
return (line)
def xmlWrapperLoot(id, x,y,item):
'''Wrap item line in xml format for Fixed loot items
'''
line = '<object id="'+ str(id)+'" name="Timo" type="FixedLoot" x="'+str(x*24)+'" y="'+str(y*24)+'" width="24" height="24">\n'
line +=' <properties>\n'
line +=' <property name="item" value="'+str(item)+'"/>\n'
line +=' </properties>\n'
line +=' </object>\n'
return (line)
def itemsDLC():
'''Read itemsDlc.list file and generate dict containing "item:dlc"
'''
fName = "itemsDlc.list"
# RiseOfTheGiant is free dlc
dlcs = ['TheBadSeed', 'FatalFalls', 'TheQueenAndTheSea', 'Purple']
dlcDict = [],
tbs = []
ff = []
tqats = []
purple = []
with open(fName,"r") as f:
for line in f.readlines():
if '"dlc"' in line:
# Format line
line = line.replace(",","")
line = line[:-1].replace(" ","")
line = line.replace('"',"")
# Parse line
cat = line.split("/")[2]
i1 = line.index("---")+3
i2 = line.index(".json")
item = line[i1:i2]
dlc = line.split(":")[2]
if dlc == dlcs[0]:
tbs.append(item)
elif dlc == dlcs[1]:
ff.append(item)
elif dlc == dlcs[2]:
tqats.append(item)
elif dlc == dlcs[3]:
purple.append(item)
'''
if cat in ["Melee","Ranged","Shield"]:
subDictWeapon[item] = dlc
elif cat in ["Power","DeployedTrap"]:
subDictSkill[item] = dlc
elif cat in ["Skin"]:
subDictSkin[item] = dlc
elif cat in ["Meta"]:
subDictMeta[item] = dlc
'''
return dlcs, [tbs,ff, tqats,purple]
def isInBlacklist(item):
'''Check if the item is in the blacklist
Some two-hand weapons may have two names but only one blueprint is needed
'''
blackList = [
"StartSword", "StartBow","StartShield" ,
"BossRune1", "BossRune2", "BossRune3", "BossRune4", "BossRune5", "BackPackKey",
# Weapons
"HardLightGun", "SnakeSwordWeaponAlt", "SnakeSwordSwap","RichterVampireKiller", "RichterCross", "CatAttack",
# skills
"ExplodeFriendlyHardy","FlyingSwordCallback","OwlUp","BackDash"
]
keyWords = [ "OffHand", "theRight", "Broken"]
for key in keyWords:
if key in item:
return True
if item in blackList:
return True
else:
return False
return