spells: have components working too
parent
a57b6577f8
commit
cfdef83cb2
|
@ -46,13 +46,17 @@ def main():
|
||||||
stypes = c.fetchall()
|
stypes = c.fetchall()
|
||||||
|
|
||||||
# TODO FIX THIS FOR SPELL COMPONENTS
|
# TODO FIX THIS FOR SPELL COMPONENTS
|
||||||
|
# CREATE TABLE spellcomponents (
|
||||||
|
# spellcomponents_id INTEGER PRIMARY KEY,
|
||||||
|
# name TEXT NOT NULL UNIQUE
|
||||||
|
# );
|
||||||
|
|
||||||
# load in ids for spelltypes from spelltypes table so we only call this once
|
# load in ids for spelltypes from spelltypes table so we only call this once
|
||||||
# instead of every spell
|
# instead of every spell
|
||||||
stmt = "SELECT spelltypes_id, name FROM spelltypes"
|
stmt = "SELECT spellcomponents_id, name FROM spellcomponents"
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute(stmt)
|
c.execute(stmt)
|
||||||
stypes = c.fetchall()
|
ctypes = c.fetchall()
|
||||||
|
|
||||||
# List the various triggers and see if there are any duplicates
|
# List the various triggers and see if there are any duplicates
|
||||||
# THERE ARE NOT IN THE CRB SO NOT BOTHERING WITH SEPARATE TRIGGERS TABLE YET
|
# THERE ARE NOT IN THE CRB SO NOT BOTHERING WITH SEPARATE TRIGGERS TABLE YET
|
||||||
|
@ -73,15 +77,33 @@ def main():
|
||||||
do_sources_pages(i,id,conn)
|
do_sources_pages(i,id,conn)
|
||||||
do_spell_traits(i,id,conn,traits)
|
do_spell_traits(i,id,conn,traits)
|
||||||
do_spell_types(i,id,conn,stypes)
|
do_spell_types(i,id,conn,stypes)
|
||||||
# TODO spell components
|
do_spell_components(i,id,conn,ctypes)
|
||||||
# TODO spell targets
|
# TODO spell targets
|
||||||
|
|
||||||
|
def do_spell_components(i,id,conn,ctypes):
|
||||||
|
res = None
|
||||||
|
for j in ctypes:
|
||||||
|
for k in i['components']:
|
||||||
|
if k.capitalize() == j[1]:
|
||||||
|
res = j[0]
|
||||||
|
|
||||||
|
inp = (res, id)
|
||||||
|
|
||||||
|
stmt = "INSERT INTO spells_spellcomponents (spells_id, spellcomponents_id) VALUES (?,?)"
|
||||||
|
|
||||||
|
try:
|
||||||
|
conn.execute(stmt, inp)
|
||||||
|
except:
|
||||||
|
print("Error inserting spell components")
|
||||||
|
else:
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
def do_spell_types(i,id,conn,stypes):
|
def do_spell_types(i,id,conn,stypes):
|
||||||
res = 0
|
res = 0
|
||||||
for j in stypes:
|
for j in stypes:
|
||||||
if i['type'] == j[1]:
|
if i['type'] == j[1]:
|
||||||
res = j[0]
|
res = j[0]
|
||||||
print(id , res)
|
# print(id , res)
|
||||||
|
|
||||||
inp = (res, id)
|
inp = (res, id)
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ CREATE TABLE spells (
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE spells_spellcomponents(
|
CREATE TABLE spells_spellcomponents(
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
spells_id INTEGER NOT NULL,
|
spells_id INTEGER NOT NULL,
|
||||||
spellcomponents_id INTEGER NOT NULL,
|
spellcomponents_id INTEGER NOT NULL,
|
||||||
FOREIGN KEY (spells_id) REFERENCES spells(spells_id),
|
FOREIGN KEY (spells_id) REFERENCES spells(spells_id),
|
||||||
|
|
Loading…
Reference in New Issue