spelltargets_id on spells now populating

merge-requests/29/head
James Miller 2019-08-10 16:06:38 -05:00
parent b2df5a9ae3
commit 6fa96a8013
1 changed files with 26 additions and 0 deletions

View File

@ -89,6 +89,11 @@ def main():
else: else:
conn.commit() conn.commit()
# load in ids for targets so just doing this once
stmt = "SELECT spelltargets_id, name FROM spelltargets"
c = conn.cursor()
c.execute(stmt)
ttypes = c.fetchall()
@ -106,6 +111,7 @@ def main():
do_spell_traits(i,id,conn,traits) do_spell_traits(i,id,conn,traits)
do_spell_types(i,id,conn,stypes) do_spell_types(i,id,conn,stypes)
do_spell_components(i,id,conn,ctypes) do_spell_components(i,id,conn,ctypes)
do_spell_targets(i,id,conn,ttypes)
# TODO spell targets # TODO spell targets
def do_spell_components(i,id,conn,ctypes): def do_spell_components(i,id,conn,ctypes):
@ -126,6 +132,26 @@ def do_spell_components(i,id,conn,ctypes):
else: else:
conn.commit() conn.commit()
def do_spell_targets(i,id,conn,ttypes):
if 'targets' not in i:
return
res = 0
for j in ttypes:
if i['targets'] == j[1]:
res = j[0]
# print(id , res)
inp = (res, id)
stmt = "UPDATE spells SET spelltargets_id=? WHERE spells_id=?"
try:
conn.execute(stmt, inp)
except:
print("Error updating spelltargets_id")
else:
conn.commit()
def do_spell_types(i,id,conn,stypes): def do_spell_types(i,id,conn,stypes):
res = 0 res = 0
for j in stypes: for j in stypes: