fix spells and actions to link up with a actioncosts_id FK in spells

This commit is contained in:
jrmiller82 committed 2019-08-12 22:41:25 -05:00
1 parent dbffbcabf0
commit f36c4856f9
4 files changed
+37 -9

No files matched your search

+26 -2
View File
@@ -95,13 +95,16 @@ def main():
c.execute(stmt)
ttypes = c.fetchall()
# load in ids for actions so just doing this once
stmt = "SELECT actioncosts_id, abbr FROM actioncosts"
c = conn.cursor()
c.execute(stmt)
acttypes = c.fetchall()
# print(sorted(targs))
# print(len(targs))
# print(len(set(targs)))
id = 0
for i in sorted_dicts:
id += 1
@@ -112,6 +115,27 @@ def main():
do_spell_types(i,id,conn,stypes)
do_spell_components(i,id,conn,ctypes)
do_spell_targets(i,id,conn,ttypes)
do_spell_actions(i,id,conn,acttypes)
def do_spell_actions(i,id,conn,acttypes):
if 'action' not in i:
return
res = 0
for j in acttypes:
if i['action'] == j[1]:
res = j[0]
# print(id , res)
inp = (res, id)
stmt = "UPDATE spells SET actioncosts_id=? WHERE spells_id=?"
try:
conn.execute(stmt, inp)
except:
print("Error updating actioncosts_id")
else:
conn.commit()
def do_spell_components(i,id,conn,ctypes):
res = None