mirror of
https://gitlab.com/jrmiller82/pathfinder-2-sqlite.git
synced 2026-10-12 22:29:44 -04:00
fix spells and actions to link up with a actioncosts_id FK in spells
This commit is contained in:
1 parent
dbffbcabf0
commit
f36c4856f9
4 files changed
+37
-9
No files matched your search
+7
-6
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user