From 83f140d3a6e58b27a56eedafa4bad84a26803bb8 Mon Sep 17 00:00:00 2001 From: James Miller Date: Sat, 10 Aug 2019 15:13:24 -0500 Subject: [PATCH] spells now have triggers working in them --- data/third_party_json/spells.py | 23 ++++++++++++++++++----- schema/spells.sql | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/data/third_party_json/spells.py b/data/third_party_json/spells.py index f17c08b..0649165 100644 --- a/data/third_party_json/spells.py +++ b/data/third_party_json/spells.py @@ -46,17 +46,25 @@ def main(): stypes = c.fetchall() # print(traits) + # 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 + ### trigs = [] + ### for i in sorted_dicts: + ### if 'trigger' in i: + ### trigs.append(i['trigger']) + ### print(sorted(trigs)) + ### print(len(trigs)) + ### print(len(set(trigs))) + id = 0 for i in sorted_dicts: id += 1 - # insert basics of a spell do_basic_sql(i, id, conn) do_range_numbers(i,id,conn) do_sources_pages(i,id,conn) do_spell_traits(i,id,conn,traits) do_spell_types(i,id,conn,stypes) - # TODO do all the traits, FK stuff etc... def do_spell_types(i,id,conn,stypes): res = 0 @@ -169,8 +177,9 @@ def do_basic_sql(i, id, conn): name, level, descr, - range_text) - VALUES (?,?,?,?,?,?,?,?)""" + range_text, + trigger) + VALUES (?,?,?,?,?,?,?,?,?)""" rge = None if 'range' in i: @@ -180,7 +189,11 @@ def do_basic_sql(i, id, conn): if 'description' in i: dscr = i['description'] - inp = (id, 1, i['source'], i['nethysUrl'], i['name'], i['level'], dscr, rge) + trg = None + if 'trigger' in i: + trg = i['trigger'] + + inp = (id, 1, i['source'], i['nethysUrl'], i['name'], i['level'], dscr, rge, trg) try: conn.execute(stmt, inp) except: diff --git a/schema/spells.sql b/schema/spells.sql index d2efcda..1fd9042 100644 --- a/schema/spells.sql +++ b/schema/spells.sql @@ -32,7 +32,7 @@ CREATE TABLE spells ( sources_pages TEXT, -- generated in spells.py from scraped data name TEXT NOT NULL UNIQUE, -- scraped from github repo level INTEGER, -- scraped from github repo - trigger TEXT, -- TODO in spells.py + trigger TEXT, -- scraped from spells.py NOTE, there are no duplicate triggers as of CRB, so not bothering with a separate spell triggers table at this time descr TEXT, -- scraped from github repo spelltypes_id INTEGER, -- generated from spells.py range_text TEXT, -- scraped from github repo