still cleaning up monsters
parent
675e703bdb
commit
16f5934daa
|
@ -1,4 +1,5 @@
|
||||||
import yaml
|
import yaml
|
||||||
|
import re
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
@ -37,8 +38,8 @@ def main():
|
||||||
i['saves_special'][k] = a[1]
|
i['saves_special'][k] = a[1]
|
||||||
i['saves'][k] = a[0]
|
i['saves'][k] = a[0]
|
||||||
elif '(' in v:
|
elif '(' in v:
|
||||||
print("we got a parentheses")
|
#print("we got a parentheses")
|
||||||
print(v)
|
#print(v)
|
||||||
a = v.split(' (')
|
a = v.split(' (')
|
||||||
# print(a)
|
# print(a)
|
||||||
i['saves_special'][k] = a[1]
|
i['saves_special'][k] = a[1]
|
||||||
|
@ -57,7 +58,72 @@ def main():
|
||||||
res.append(z.strip())
|
res.append(z.strip())
|
||||||
i['immunities'] = res
|
i['immunities'] = res
|
||||||
|
|
||||||
print(i['immunities'])
|
# clean up traits with trailing or leading whitespace
|
||||||
|
traitslist = []
|
||||||
|
print(i['traits'])
|
||||||
|
for x in i['traits']:
|
||||||
|
traitslist.append(x.strip())
|
||||||
|
print(x.strip())
|
||||||
|
print(traitslist)
|
||||||
|
i['traits'] = traitslist
|
||||||
|
|
||||||
|
# clean up traits underneath proactive actions with trailing or leading whitespace
|
||||||
|
print(i['proactive_abilities'])
|
||||||
|
for x in i['proactive_abilities']:
|
||||||
|
traitslist = []
|
||||||
|
if x['traits'] != None:
|
||||||
|
if len(x['traits']) == 0:
|
||||||
|
x['traits'] = None
|
||||||
|
else:
|
||||||
|
for y in x['traits']:
|
||||||
|
traitslist.append(y.strip())
|
||||||
|
print(y.strip())
|
||||||
|
x['traits'] = traitslist
|
||||||
|
|
||||||
|
# clean up senses
|
||||||
|
|
||||||
|
senseslist = []
|
||||||
|
if i['senses'] != None:
|
||||||
|
if len(i['senses']) == 0:
|
||||||
|
i['senses'] = None
|
||||||
|
else:
|
||||||
|
for x in i['senses']:
|
||||||
|
senseslist.append(x.strip())
|
||||||
|
i['senses'] = senseslist
|
||||||
|
|
||||||
|
# clean up spell DC
|
||||||
|
if i['spell_dc'] == "None":
|
||||||
|
i['spell_dc'] = None
|
||||||
|
else:
|
||||||
|
i['spell_dc'] = int(i['spell_dc'])
|
||||||
|
|
||||||
|
# clean up innate_spell levels
|
||||||
|
if 'innate_spells' not in i:
|
||||||
|
i['innate_spells'] = None
|
||||||
|
elif i['innate_spells'] == "None":
|
||||||
|
i['innate_spells'] = None
|
||||||
|
else:
|
||||||
|
for x in i['innate_spells']:
|
||||||
|
x['level'] = int(x['level'])
|
||||||
|
|
||||||
|
|
||||||
|
# clean up resistances
|
||||||
|
|
||||||
|
# set Nones to null
|
||||||
|
if i['resistances'] == "None":
|
||||||
|
i['resistances'] = None
|
||||||
|
|
||||||
|
# remove trailing ;
|
||||||
|
elif i['resistances'].endswith(";"):
|
||||||
|
i['resistances'] = i['resistances'][:-1]
|
||||||
|
#print("\t{}".format(i['resistances']))
|
||||||
|
|
||||||
|
if i['resistances'] != None:
|
||||||
|
#print("{}\t{}".format(counter, i['name']))
|
||||||
|
#print("\t{}".format(i['resistances']))
|
||||||
|
res = processResistances(i['resistances'])
|
||||||
|
i['resistances'] = res
|
||||||
|
#print(res)
|
||||||
|
|
||||||
final = yaml.safe_dump(data, allow_unicode=True)
|
final = yaml.safe_dump(data, allow_unicode=True)
|
||||||
|
|
||||||
|
@ -65,6 +131,33 @@ def main():
|
||||||
with open("tmp-monsters.yaml", 'w') as f:
|
with open("tmp-monsters.yaml", 'w') as f:
|
||||||
f.write(final)
|
f.write(final)
|
||||||
|
|
||||||
|
def processResistances(r):
|
||||||
|
if '(' in r:
|
||||||
|
# TODO This is what needs to be done
|
||||||
|
#print("\t\tTODO: Need to process with parentheses")
|
||||||
|
return r
|
||||||
|
else:
|
||||||
|
#print("\t\tNo parentheses")
|
||||||
|
# split on commas
|
||||||
|
res = r.split(',')
|
||||||
|
#print(r.split(','))
|
||||||
|
#print(res)
|
||||||
|
results_list = []
|
||||||
|
for i in res:
|
||||||
|
#print(i)
|
||||||
|
#tmp = re.search('(\d+)', i)
|
||||||
|
#print(tmp.groups())
|
||||||
|
tmp = re.split('(\d+)', i)
|
||||||
|
#print(tmp)
|
||||||
|
tmpres = {"type": tmp[0].strip(), "amount": int(tmp[1])}
|
||||||
|
results_list.append(tmpres)
|
||||||
|
|
||||||
|
return results_list
|
||||||
|
|
||||||
|
|
||||||
|
return "Something went wrong"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -2988,7 +2988,7 @@
|
||||||
fort: "+25,"
|
fort: "+25,"
|
||||||
hp: "250 (negative healing);"
|
hp: "250 (negative healing);"
|
||||||
immunities: "disease, paralyzed, poison, precision, unconscious"
|
immunities: "disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all damage 12 (except force,"
|
resistances: "all damage 12 (except force, ghost touch, or positive; double resistance vs. non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Spectral Ripple"
|
name: "Spectral Ripple"
|
||||||
|
@ -17935,7 +17935,7 @@
|
||||||
fort: "+8,"
|
fort: "+8,"
|
||||||
hp: "30 (negative healing, rejuvenation);"
|
hp: "30 (negative healing, rejuvenation);"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all damage 5 (except force,"
|
resistances: "all damage 5 (except force, ghost touch, or positive; double resistance vs. non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Frightful Moan"
|
name: "Frightful Moan"
|
||||||
|
@ -18006,7 +18006,7 @@
|
||||||
fort: "+16,"
|
fort: "+16,"
|
||||||
hp: "135 (negative healing, rejuvenation);"
|
hp: "135 (negative healing, rejuvenation);"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all damage 10 (except force,"
|
resistances: "all damage 10 (except force, ghost touch, or positive; double resistance vs. non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Frightful Moan"
|
name: "Frightful Moan"
|
||||||
|
@ -20131,7 +20131,7 @@
|
||||||
fort: "+33,"
|
fort: "+33,"
|
||||||
hp: "255 (repair mode);"
|
hp: "255 (repair mode);"
|
||||||
immunities: "bleed, death effects, disease, doomed, drained, fatigued, fire, healing, magic (see below), mental, necromancy, nonlethal attacks, paralyzed, poison, sickened, unconscious"
|
immunities: "bleed, death effects, disease, doomed, drained, fatigued, fire, healing, magic (see below), mental, necromancy, nonlethal attacks, paralyzed, poison, sickened, unconscious"
|
||||||
resistances: "physical 20 (except"
|
resistances: "physical 20 (except vorpal adamantine)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Destructive Strike"
|
name: "Destructive Strike"
|
||||||
|
@ -27598,7 +27598,7 @@
|
||||||
fort: "+9,"
|
fort: "+9,"
|
||||||
hp: "55 (rejuvenation);"
|
hp: "55 (rejuvenation);"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all damage 5 (except force,"
|
resistances: "all damage 5 (except force, ghost touch, or positive; double resistance against non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Frighten"
|
name: "Frighten"
|
||||||
|
@ -30125,7 +30125,7 @@
|
||||||
fort: "+8,"
|
fort: "+8,"
|
||||||
hp: "40;"
|
hp: "40;"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all 5 (except force,"
|
resistances: "all 5 (except force, ghost touch, or positive; double resistance against non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Shadow Spawn"
|
name: "Shadow Spawn"
|
||||||
|
@ -30189,7 +30189,7 @@
|
||||||
fort: "+11,"
|
fort: "+11,"
|
||||||
hp: "75;"
|
hp: "75;"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all 10 (except force,"
|
resistances: "all 10 (except force, ghost touch, or positive; double resistance against non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Shadow Spawn"
|
name: "Shadow Spawn"
|
||||||
|
@ -34611,7 +34611,7 @@
|
||||||
fort: "+8,"
|
fort: "+8,"
|
||||||
hp: "80 (negative healing);"
|
hp: "80 (negative healing);"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all 5 (except force,"
|
resistances: "all 5 (except force, ghost touch, or positive; double resistance against non-magical)"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Drain Life"
|
name: "Drain Life"
|
||||||
|
@ -38017,7 +38017,7 @@
|
||||||
fort: "+14,"
|
fort: "+14,"
|
||||||
hp: "135;"
|
hp: "135;"
|
||||||
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
immunities: "death effects, disease, paralyzed, poison, precision, unconscious"
|
||||||
resistances: "all damage 8 (except force,"
|
resistances: "all 8 (except force, ghost touch, or positive; double resistance against non-magical), haunted form"
|
||||||
proactive_abilities:
|
proactive_abilities:
|
||||||
-
|
-
|
||||||
name: "Create Haunt"
|
name: "Create Haunt"
|
||||||
|
|
Loading…
Reference in New Issue