got resistances cleaned up
parent
2135c80654
commit
b6fe620169
|
@ -228,14 +228,14 @@ def main():
|
||||||
if i['resistances'] != None:
|
if i['resistances'] != None:
|
||||||
#print("{}\t{}".format(counter, i['name']))
|
#print("{}\t{}".format(counter, i['name']))
|
||||||
#print("\t{}".format(i['resistances']))
|
#print("\t{}".format(i['resistances']))
|
||||||
print("{}\t{}".format(counter, i['name']))
|
# print("{}\t{}".format(counter, i['name']))
|
||||||
res = processResistances(i['resistances'])
|
res = processResistances(i['resistances'])
|
||||||
i['resistances'] = res
|
i['resistances'] = res
|
||||||
#print(res)
|
#print(res)
|
||||||
|
|
||||||
if type(i['resistances']) == str:
|
#if type(i['resistances']) == str:
|
||||||
print("{}\t{}".format(counter, i['name']))
|
# print("{}\t{}".format(counter, i['name']))
|
||||||
print("\t\t\t\t{}".format(i['resistances']))
|
# print("\t\t\t\t{}".format(i['resistances']))
|
||||||
|
|
||||||
# clean up speeds
|
# clean up speeds
|
||||||
newspeed = []
|
newspeed = []
|
||||||
|
@ -350,16 +350,38 @@ def processResistances(r):
|
||||||
|
|
||||||
# this tree does the simple ones without multiple items
|
# this tree does the simple ones without multiple items
|
||||||
if ',' not in r:
|
if ',' not in r:
|
||||||
print(r)
|
|
||||||
rr = re.split('(\d+)', r)
|
rr = re.split('(\d+)', r)
|
||||||
#for i, s in enumerate(rr):
|
|
||||||
# rr[i] = s.strip()
|
|
||||||
print(rr)
|
|
||||||
return [{"type": rr[0].strip() + ' ' + rr[2].strip(), "amount": int(rr[1])},]
|
return [{"type": rr[0].strip() + ' ' + rr[2].strip(), "amount": int(rr[1])},]
|
||||||
elif ',' in r:
|
elif ',' in r:
|
||||||
# TODO This is the next needed step
|
# FIGURE OUT BRANCH FOR THE COMMA IS NOT INSIDE THE PARENTHETICAL
|
||||||
return None
|
test = re.search('(\(.+\))', r)
|
||||||
|
tstr = test.group(0)
|
||||||
|
if ',' in tstr:
|
||||||
|
# TODO here's the case for comma IS inside the parenthetical
|
||||||
|
print("\n")
|
||||||
|
print(r)
|
||||||
|
if 'haunted form' not in r:
|
||||||
|
# DO the majority of them
|
||||||
|
rr = re.split('(\d+)', r)
|
||||||
|
print(rr)
|
||||||
|
return [{"type": rr[0].strip() + ' ' + rr[2].strip(), "amount": int(rr[1])},]
|
||||||
|
elif 'haunted form' in r:
|
||||||
|
# DO the single haunted form one
|
||||||
|
##### NOTE I'm hard coding this in as it will be faster than writing regex
|
||||||
|
result = [{"type": "all (except force, ghost touch, or positive; double resistance against non-magical)", "amount": 8},
|
||||||
|
{"type": "haunted form", "amount": 12}]
|
||||||
|
print(result)
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
# TODO Here's the case for comma is NOT inside the parenthetical
|
||||||
|
splits = re.split(',', r)
|
||||||
|
mysplitlist = []
|
||||||
|
for x in splits:
|
||||||
|
rr = re.split('(\d+)', x)
|
||||||
|
mysplitlist.append({"type": rr[0].strip() + ' ' + rr[2].strip(), "amount": int(rr[1])})
|
||||||
|
return mysplitlist
|
||||||
else:
|
else:
|
||||||
|
print("else has been run")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
#print("\t\tNo parentheses")
|
#print("\t\tNo parentheses")
|
||||||
|
|
Loading…
Reference in New Issue