From df2bdacc565c2b136e40f543c1577cf5aeb7bde4 Mon Sep 17 00:00:00 2001
From: James Miller <james.ryland.miller@gmail.com>
Date: Thu, 14 Nov 2019 22:42:38 -0600
Subject: [PATCH] got requirements.yamls and YAML->SQL working

---
 data/yaml/gendb.py          | 35 ++++++++++++++++---
 data/yaml/requirements.yaml | 67 +++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 4 deletions(-)
 create mode 100644 data/yaml/requirements.yaml

diff --git a/data/yaml/gendb.py b/data/yaml/gendb.py
index 37bf0af..9a0b912 100644
--- a/data/yaml/gendb.py
+++ b/data/yaml/gendb.py
@@ -72,10 +72,38 @@ def main():
     do_actions(data, conn)
 
     # move on to spells
+    # TODO do spells once data is proofread
     with open('spells.yaml') as yl:
         data = yaml.full_load(yl)
     do_spells(data, conn)
 
+    # move on to requirements
+    with open('requirements.yaml') as yl:
+        data = yaml.full_load(yl)
+    do_requirements(data, conn)
+
+def do_requirements(data, conn):
+    table = """
+CREATE TABLE requirement (
+  requirement_id INTEGER PRIMARY KEY,
+  descr TEXT NOT NULL UNIQUE
+);
+   """
+
+    c = conn.cursor()
+    c.execute(table)
+
+    inp_data = []
+    for i in data['requirement']:
+        inp_data.append((i, ))
+
+    stmt = "INSERT INTO requirement (descr) VALUES (?)"
+    try:
+        conn.executemany(stmt, inp_data)
+    except Exception as e:
+        print("Error creating requirement: {}".format(e))
+    else:
+        conn.commit()
 
 def do_spells(data, conn):
     # load the helper info
@@ -83,6 +111,7 @@ def do_spells(data, conn):
     do_spellcomponent(data, conn)
     do_spelltradition(data, conn)
     do_spellschool(data, conn)
+    # TODO once spells data complete, write a do_spellsthemselves(data, conn) function
 
 
 def do_spelltype(data, conn):
@@ -202,10 +231,8 @@ VALUES (?,?,
         """
         # print('executing on name:{}'.format(i['name']))
         try:
-            conn.execute(
-                stmt,
-                (i['name'], i['descr'], srcentrydata[0][0],
-                 srcentrydata[0][1], srcentrydata[0][2]))
+            conn.execute(stmt, (i['name'], i['descr'], srcentrydata[0][0],
+                                srcentrydata[0][1], srcentrydata[0][2]))
         except Exception as e:
             print("Error creating spellschool: {}".format(e))
         else:
diff --git a/data/yaml/requirements.yaml b/data/yaml/requirements.yaml
new file mode 100644
index 0000000..c45e91c
--- /dev/null
+++ b/data/yaml/requirements.yaml
@@ -0,0 +1,67 @@
+requirement:
+- You are holding an infused alchemical bomb you crafted, with a level at least 3 lower than your advanced alchemy level.
+- "You haven't used this ability since you last Raged."
+- You are Medium or smaller.
+- You have a foe grabbed.
+- Your last action was a successful Strike.
+- Your last action was a successful Strike, and either you have a hand free or your Strike used a grapple weapon.
+- You are unarmored or wearing light armor.
+- "You're under the effect of Come and Get Me."
+- "You haven't acted yet on your turn."
+- You are wielding a shield.
+# Fiendsbane Oath may be errated to a requirement. Marking it incase to find easier.
+- Fiendsbane Oath'
+# Shining Oath may be errated to a requirement. Marking it incase to find easier.
+- Shining Oath
+- exalt and Vengeful Oath
+- Dragonslayer Oath
+- You have a banishment spell prepared.
+- You have at least 1 available Focus Point.
+- You are wielding two melee weapons, each in a different hand.
+- You are wielding a ranged weapon.
+- You have one hand free, and your target is within reach of that hand.
+- You are wielding a two-handed melee weapon.
+- You are wielding only a single one-handed melee weapon and have your other hand or hands free.
+- You are wielding a melee weapon.
+- You are wielding a ranged weapon with reload 0.
+- You are wielding a one-handed melee weapon and have a free hand.
+- You are flanked by at least two enemies.
+- You are wielding two melee weapons, one in each hand.
+- You are wielding a single one-handed melee weapon and have your other hand or hands free.
+- You are wielding a melee weapon that deals piercing damage.
+- A frightened creature is in your melee reach.
+- You are benefiting from Dueling Parry.
+- You are wielding a two-handed melee weapon and your target is within your reach.
+- You have a shield raised.
+- You are wielding a melee weapon in two hands.
+- You are adjacent to an enemy.
+- You meet the requirements to use an action with the press trait.
+- You are wielding two weapons, each in a different hand.
+- You are wielding a ranged weapon with the volley trait and reload 0.
+- You are unarmored.
+- You are unarmored and touching the ground.
+- "You're aware of the attack, are not flat-footed against it, and have a hand free."
+- You are in Crrane Stance.
+- You are in Dragon Stance.
+- You are in Mountain Stance.
+- You are in Tiger Stance.
+- You have a creature grabbed or restrained.
+- You are in Wolf Stance.
+- You are in Ironblood Stance.
+- You are in Tangled Forest Stance.
+- You are in Wild Winds Stance.
+- This is the first action of your turn.
+- You are not armored or fatigued.
+- You are benefiting from Twin Parry.
+- You are wielding a loaded ranged weapon with reload 1 or more, and you have not reloaded your weapon since your last turn.
+- You are not encumbered.
+- You are wielding a piercing or slashing weapon and have a free hand.
+- You have a free hand.
+- Your last action was a melee Strike that dealt sneak attack damage to a flat-footed target.
+- You are currently affected by a mental effect that you gained by failing, but not critically failing, a saving throw.
+- You are adjacent to a floor or vertical wall.
+- When you make your daily preparations, you must specify a trigger for this reaction using the same restrictions as the triggers for the Ready action. You also choose a single spell from the arcane, divine, occult, or primal list of 4th level or lower. The spell can’t have a cost, nor can its casting time be more than 10 minutes. The spell must be able to target a single creature, and you must be a valid target for it.
+- You have Perfect Distraction ready to use.
+- You have an unexpended spell slot you could use to cast the triggered spell.
+- Your most recent action was to cast a non-cantrip spell.
+- The last action you used was Drain Bonded Item.