From 8dfd8c0a26cb69f1b6b0dafe3c6bc0bf9d45a198 Mon Sep 17 00:00:00 2001 From: James Miller Date: Mon, 20 Apr 2020 21:57:12 -0500 Subject: [PATCH] fix some data, and have heritages except the feat working --- data/yaml/ancestriesheritages.yaml | 43 ++++++++++++++++++------------ gendb/gendb.py | 34 ++++++++++++++++++++--- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/data/yaml/ancestriesheritages.yaml b/data/yaml/ancestriesheritages.yaml index fe82d8c..b5ac249 100644 --- a/data/yaml/ancestriesheritages.yaml +++ b/data/yaml/ancestriesheritages.yaml @@ -90,13 +90,6 @@ ancestries: Climb). This doesn’t affect you if you’re using a climb Speed. feat: null name: Woodland Elf - - &id001 - descr: Either one of your parents was an elf, or one or both were half-elves. - You have pointed ears and other telltale signs of elf heritage. You gain the - elf trait and low-light vision. In addition, you can select elf, half-elf, and - human feats whenever you gain an ancestry feat. - feat: null - name: Half-Elf hp: 6 name: Elf senses: Low-Light Vision @@ -274,7 +267,30 @@ ancestries: - Free2 flavor_text: TODO flaws: null - heritages: [] + heritages: + - descr: Either one of your parents was an elf, or one or both were half-elves. You + have pointed ears and other telltale signs of elf heritage. You gain the elf trait + and low-light vision. In addition, you can select elf, half-elf, and human feats + whenever you gain an ancestry feat. + feat: null + name: Half-Elf + - descr: One of your parents was an orc, or one or both were half-orcs. You have a + green tinge to your skin and other indicators of orc heritage. You gain the orc + trait and low-light vision. In addition, you can select orc, half-orc, and human + feats whenever you gain an ancestry feat. + feat: null + name: Half-Orc + - descr: Your ingenuity allows you to train in a wide variety of skills. You become + trained in one skill of your choice. At 5th level, you become an expert in the + chosen skill. + feat: null + name: Skilled Heritage + - descr: Humanity’s versatility and ambition have fueled its ascendance to be the + most common ancestry in most nations throughout the world. Select a general feat + of your choice for which you meet the prerequisites (as with your ancestry feat, + you can select this general feat at any point during character creation). + feat: null + name: Versatile Heritage hp: 8 name: Human senses: None @@ -290,8 +306,7 @@ ancestries: - boosts: null flavor_text: TODO flaws: null - heritages: - - *id001 + heritages: [] hp: 8 name: Half-Elf senses: None @@ -309,13 +324,7 @@ ancestries: - boosts: null flavor_text: TODO flaws: null - heritages: - - descr: One of your parents was an orc, or one or both were half-orcs. You have - a green tinge to your skin and other indicators of orc heritage. You gain the - orc trait and low-light vision. In addition, you can select orc, half-orc, and - human feats whenever you gain an ancestry feat. - feat: null - name: Half-Orc + heritages: [] hp: 8 name: Half-Orc senses: None diff --git a/gendb/gendb.py b/gendb/gendb.py index 6d793b3..1f2be1e 100644 --- a/gendb/gendb.py +++ b/gendb/gendb.py @@ -120,16 +120,44 @@ def main(): data = yaml.full_load(yl) do_ammo(data, conn) - # move on to ammo with open('gear.yaml') as yl: data = yaml.full_load(yl) do_gear(data, conn) - # move on to ammo - with open('ancestries.yaml') as yl: + with open('ancestriesheritages.yaml') as yl: data = yaml.full_load(yl) do_ancestries(data, conn) + with open('ancestriesheritages.yaml') as yl: + data = yaml.full_load(yl) + do_heritages(data, conn) + +def do_heritages(data, conn): + table = """ + CREATE TABLE heritages ( + heritage_id INTEGER PRIMARY KEY, + name TEXT NOT NULL UNIQUE, + descr TEXT NOT NULL, + ancestry_id INTEGER NOT NULL, -- many to one relationship + FOREIGN KEY (ancestry_id) REFERENCES ancestries(ancestry_id) + ); + """ + + c = conn.cursor() + c.execute(table) + + for i in data['ancestries']: + #GET ID OF ANCESTRY + stmt = "SELECT ancestry_id FROM ancestries WHERE name=?;" + c.execute(stmt, (i['name'],)) + rowid = c.fetchone() + #FOR EACH HERITAGE, INSERT INTO TABLE USING ANCESTRY ID + for j in i['heritages']: + print("doing this heritage: {}".format(j['name'])) + stmt = "INSERT INTO heritages (name, descr, ancestry_id) VALUES (?,?,?);" + c.execute(stmt, (j['name'], j['descr'], rowid[0])) + conn.commit() + def do_ancestries(data, conn): # create tables