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

merge-requests/30/merge
James Miller 2019-08-12 22:41:25 -05:00
parent dbffbcabf0
commit f36c4856f9
4 changed files with 37 additions and 9 deletions

View File

@ -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

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

View File

@ -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
);

View File

@ -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)