Magic items now can add to saving throw modifiers, and added

Ankylosaurus back in.

This is all or nothing at the moment, so all saving throws get the
same bonus.

Fixes: https://github.com/canismarko/dungeon-sheets/issues/101
This commit is contained in:
Mark Wolfman
2021-08-05 21:34:27 -05:00
parent a1659873dc
commit a18b6df3bb
4 changed files with 49 additions and 9 deletions
+9 -8
View File
@@ -6,6 +6,7 @@ class MagicItem:
name = ""
ac_bonus = 0
st_bonus = 0
requires_attunement = False
needs_implementation = False
rarity = ""
@@ -22,25 +23,25 @@ class MagicItem:
class CloakOfProtection(MagicItem):
"""You gain a +1 bonus to AC and Saving Throws while wearing this
cloak.
"""
You gain a +1 bonus to AC and Saving Throws while wearing this cloak.
"""
name = "Cloak of Protection"
ac_bonus = 1
st_bonus = 1
requires_attunement = True
rarity = "Uncommon"
class RingOfProtection(MagicItem):
"""You gain a +1 bonus to AC and Saving Throws while wearing this
ring.
"""
You gain a +1 bonus to AC and Saving Throws while wearing this ring.
"""
name = "Ring of Protection"
ac_bonus = 1
st_bonus = 1
requires_attunement = True
rarity = "Rare"
item_type = "Ring"
+33
View File
@@ -1539,6 +1539,39 @@ class Ankheg(Monster):
spells = []
class Ankylosaurus(Monster):
"""Thick armor plating covers the body of the plant-eating dinosaur
ankylosaurus, which defends itself against predators with a
knobbed tail that delivers a devastating strike.
Tail
*Melee Weapon Attack:* +7 to hit, reach 10 ft., one
target. *Hit:* 18 (4d6+4) bludgeoning damage. If the target is a
creature, it must succeed on a DC 14 Strength saving throw or be
knocked prone.
"""
# TODO: This doesn't appear to be SRD
name = "Ankylosaurus"
description = "Huge beast, unaligned"
challenge_rating = 3
armor_class = 15
skills = ""
senses = "passive Perception 11"
strength = Ability(19)
dexterity = Ability(11)
constitution = Ability(15)
intelligence = Ability(2)
wisdom = Ability(12)
charisma = Ability(5)
speed = 30
swim_speed = 0
fly_speed = 0
climb_speed = 0
hp_max = 68
hit_dice = "8d12+16"
class Ape(Monster):
"""
Multiattack.
+3
View File
@@ -76,6 +76,9 @@ class Ability:
is_proficient = self.ability_name in entity.saving_throw_proficiencies
if is_proficient:
saving_throw += entity.proficiency_bonus
# Check for bonuses to saving throws from magic items
for mitem in entity.magic_items:
saving_throw += getattr(mitem, "st_bonus", 0)
# Create the named tuple
value = AbilityScore(modifier=modifier, value=score, saving_throw=saving_throw, name=self.ability_name)
return value
+4 -1
View File
@@ -1,6 +1,6 @@
from unittest import TestCase
from dungeonsheets import stats, character
from dungeonsheets import stats, character, magic_items
class TestStats(TestCase):
@@ -18,6 +18,9 @@ class TestStats(TestCase):
my_class = MyClass()
self.assertEqual(my_class.strength.saving_throw, 4)
# Try it with a magic item
my_class.magic_items.append(magic_items.RingOfProtection)
self.assertEqual(my_class.strength.saving_throw, 5)
def test_modifier(self):
class MyCharacter(character.Character):