diff --git a/data/third_party_json/spells.py b/data/third_party_json/spells.py index ec665d6..388909e 100644 --- a/data/third_party_json/spells.py +++ b/data/third_party_json/spells.py @@ -89,6 +89,11 @@ def main(): else: 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_types(i,id,conn,stypes) do_spell_components(i,id,conn,ctypes) + do_spell_targets(i,id,conn,ttypes) # TODO spell targets def do_spell_components(i,id,conn,ctypes): @@ -126,6 +132,26 @@ def do_spell_components(i,id,conn,ctypes): else: 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): res = 0 for j in stypes: