working on triggers in feats, cleanyaml updates to triggers

bradl/monsters-adult-gold-dragon
James Miller 2020-04-21 18:35:08 -05:00
parent 83e45e6c68
commit a691f5c994
3 changed files with 36 additions and 15 deletions

View File

@ -29,6 +29,10 @@ def main():
# print("Before: {}".format(i['requirement']))
i['requirement'] = i['requirement'].replace('', "'")
# print("After: {}".format(i['requirement']))
if i['trigger'] != None:
# print("Before: {}".format(i['trigger']))
i['trigger'] = i['trigger'].replace('', "'")
# print("After: {}".format(i['trigger']))
final = yaml.safe_dump(data, allow_unicode=True)
with open(x, 'w') as f:
f.write(final)

View File

@ -40,8 +40,8 @@ feat:
page_start: 35
page_stop: 35
traits: null
trigger:
- You attempt a saving throw against a magical effect, but you haven't rolled yet.
trigger: You attempt a saving throw against a magical effect, but you haven't rolled
yet.
- actioncost: null
descr: You eagerly absorbed the old stories and traditions of your ancestors, your
gods, and your people, studying in subjects and techniques passed down for generation
@ -1639,7 +1639,7 @@ feat:
page_stop: 57
traits:
- Human
trigger: You attempt a check using a skill youre untrained in.
trigger: You attempt a check using a skill you're untrained in.
- actioncost: null
descr: Youve learned to split your focus between multiple classes with ease. You
gain a 2nd-level multiclass dedication feat (for more about multiclass archetypes,
@ -2558,7 +2558,7 @@ feat:
traits:
- Additive
- Alchemist
trigger: You craft an alchemical bomb using Quick Alchemy thats at least 2 levels
trigger: You craft an alchemical bomb using Quick Alchemy that's at least 2 levels
lower than your advanced alchemy level.
- actioncost: null
descr: Specialized tweaks to your formula that supplements your genius considerably
@ -3086,7 +3086,7 @@ feat:
traits:
- Barbarian
trigger: A creature within your reach uses a manipulate action or a move action,
makes a ranged attack, or leaves a square during a move action its using.
makes a ranged attack, or leaves a square during a move action it's using.
- actioncost: null
descr: You push your foes around and leave bruises. While raging, when you successfully
Disarm, Grapple, Shove, or Trip a foe, you deal that foe bludgeoning damage equal
@ -5125,8 +5125,8 @@ feat:
traits:
- Champion
- Flourish
trigger: A foes attack against an ally matches the trigger for both your Shield
Block reaction and your champions reaction.
trigger: A foe's attack against an ally matches the trigger for both your Shield
Block reaction and your champion's reaction.
- actioncost: null
descr: The divine grace that flows through you grants reprieve from an affliction.
When you use Mercy, you can instead attempt to counteract a curse, disease, or
@ -9244,7 +9244,7 @@ feat:
traits:
- Monk
trigger: A creature within your reach uses a move action or leaves a square during
a move action its using.
a move action it's using.
- actioncost: null
descr: You can restore your health by tapping into your ki. You gain the wholeness
of body ki spell. Increase the number of Focus Points in your focus pool by 1.
@ -10089,7 +10089,7 @@ feat:
traits:
- Fortune
- Monk
trigger: An enemys attack hits you or you fail a saving throw against an enemys
trigger: An enemy's attack hits you or you fail a saving throw against an enemy's
ability.
- actioncost: null
descr: You gain the service of a young animal companion that travels with you and
@ -10333,7 +10333,7 @@ feat:
traits:
- Ranger
trigger: Your hunted prey is within your reach, and it uses a manipulate action,
uses a move action, or leaves a square during a move action its using.
uses a move action, or leaves a square during a move action it's using.
- actioncost: null
descr: Your experience in the field has taught you how to focus your aim at a distance,
increasing your accuracy. Double your weapons range increments.
@ -12282,7 +12282,7 @@ feat:
- Manipulate
- Rogue
trigger: You would be hit by an attack or targeted by an effect, or you are within
an effects area.
an effect's area.
- actioncost: Reaction
descr: When a foe Casts a Spell you know and you can see its manifestations, you
can use your own magic to disrupt it. You expend one of your spell slots to counter
@ -16836,7 +16836,7 @@ feat:
- General
- Secret
- Skill
trigger: A creature within line of sight casts a spell that you dont have prepared
trigger: A creature within line of sight casts a spell that you don't have prepared
or in your spell repertoire, or a trap or similar object casts such a spell. You
must be aware of the casting.
- actioncost: null

View File

@ -174,14 +174,31 @@ def do_feats(data, conn):
r_id = None
else:
r_id = get_requirement_id_by_descr(i['requirement'], conn)
# print("f_id for {} is {}".format(i['frequency'], f_id))
if i['trigger'] == None:
t_id = None
else:
t_id = get_trigger_id_by_descr(i['trigger'], conn)
# res = (ac_id, i['descr'], f_id, i['level'], i['name'], r_id, t_id)
insert_stmt = "INSERT INTO feat (actioncost_id, descr, freq_id, level, name, requirement_id, trigger_id) VALUES (?,?,?,?,?,?,?);"
def get_trigger_id_by_descr(t, conn):
qstmt = "SELECT trigger_id FROM trigger WHERE descr=?;"
try:
c = conn.cursor()
c.execute(qstmt, (t,))
except sqlite3.Error as e:
print("Error getting an trigger_id by name: {} Error: {}".format(t, e))
except:
print("Error getting an trigger_id_by_name something other than sqlite3 error")
else:
x = c.fetchone()
if x == None:
raise AssertionError('there was no trigger_id for given trigger name: {}\nYou should check to see if this trigger is in triggers.yaml and sometimes it is a straight apostrophe versus uni-code curly apostrophe.'.format(t))
else:
return x[0]
def get_requirement_id_by_descr(r, conn):
qstmt = "SELECT requirement_id FROM requirement WHERE descr=?;"
try: