diff --git a/data/actions.sql b/data/actions.sql index a370b3c..764f425 100644 --- a/data/actions.sql +++ b/data/actions.sql @@ -2,14 +2,15 @@ INSERT INTO actioncosts ( actioncosts_id, - name + name, + abbr ) VALUES - (1, 'Single Action'), - (2, 'Two Actions'), - (3, 'Three Actions'), - (4, 'Free Action'), - (5, 'Reaction'); + (1, 'Single Action', '1'), + (2, 'Two Actions', '2'), + (3, 'Three Actions', '3'), + (4, 'Free Action', 'free'), + (5, 'Reaction', 'reaction'); INSERT INTO actioncategories (actioncategories_id, sources_id, sources_pages, name, descr) VALUES diff --git a/data/third_party_json/spells.py b/data/third_party_json/spells.py index 9685f18..35c34fb 100644 --- a/data/third_party_json/spells.py +++ b/data/third_party_json/spells.py @@ -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 diff --git a/schema/actions.sql b/schema/actions.sql index 7eea1da..d8aa616 100644 --- a/schema/actions.sql +++ b/schema/actions.sql @@ -2,7 +2,8 @@ CREATE TABLE actioncosts ( actioncosts_id INTEGER PRIMARY KEY, - name TEXT NOT NULL UNIQUE + name TEXT NOT NULL UNIQUE, + abbr TEXT NOT NULL UNIQUE ); diff --git a/schema/spells.sql b/schema/spells.sql index 7a5ab90..ebfc293 100644 --- a/schema/spells.sql +++ b/schema/spells.sql @@ -48,6 +48,8 @@ CREATE TABLE spells ( area_text TEXT, -- TODO need to figure out some sort of programmatic representation for this too spelltargets_id INTEGER, nethysurl TEXT, -- scraped from github repo + actioncosts_id INTEGER, + FOREIGN KEY (actioncosts_id) REFERENCES actioncosts(actioncosts_id), FOREIGN KEY (sources_id) REFERENCES sources(sources_id), FOREIGN KEY (spelltypes_id) REFERENCES spelltypes(spelltypes_id), FOREIGN KEY (spelltargets_id) REFERENCES spelltargets(spelltargets_id)