Added feature enhancements for Druid's

- Circle now properly reflects the druid's available wild_shapes
- Unavaiable wild_shapes are not listed on the sheet but ghosted.
- ``spells`` is now longer relevant, only use ``spells_prepared`` in
  the character file.
This commit is contained in:
Mark Wolfman
2018-10-31 18:16:35 -05:00
parent d2c24cfb2a
commit f10867719d
13 changed files with 370 additions and 128 deletions
+57 -33
View File
@@ -1,8 +1,9 @@
#!/usr/bin/env python
from unittest import TestCase
import warnings
from dungeonsheets import race, monsters, exceptions
from dungeonsheets import race, monsters, exceptions, spells
from dungeonsheets.character import Character, Wizard, Druid
from dungeonsheets.weapons import Weapon, Shortsword
from dungeonsheets.armor import Armor, LeatherArmor, Shield
@@ -131,6 +132,51 @@ class TestCharacter(TestCase):
self.assertEqual(char.spell_slots(spell_level=1), 3)
self.assertEqual(char.spell_slots(spell_level=2), 0)
def test_equip_armor(self):
char = Character(dexterity=16)
char.wear_armor('leather armor')
self.assertTrue(isinstance(char.armor, Armor))
# Now make sure the armor class is correct
self.assertEqual(char.armor_class, 14)
# Try passing an Armor object directly
char.wear_armor(LeatherArmor())
self.assertEqual(char.armor_class, 14)
# Test equipped armor with max dexterity mod_str
char.armor.dexterity_mod_max = 1
self.assertEqual(char.armor_class, 12)
def test_wield_shield(self):
char = Character(dexterity=16)
char.wield_shield('shield')
self.assertTrue(isinstance(char.shield, Shield), msg=char.shield)
# Now make sure the armor class is correct
self.assertEqual(char.armor_class, 15)
# Try passing an Armor object directly
char.wield_shield(Shield)
self.assertEqual(char.armor_class, 15)
def test_speed(self):
# Check that the speed pulls from the character's race
char = Character(race='halfling')
self.assertEqual(char.speed, 25)
# Check that a character with no race defaults to 30 feet
char = Character()
char.race = None
self.assertEqual(char.speed, 30)
class DruidTestCase(TestCase):
def test_learned_spells(self):
"""For a druid, learning spells is not necessary and this field should
be ignored."""
char = Druid()
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message="Druids cannot learn spells")
char.set_attrs(spells=['invisibility'],
spells_prepared=['druidcraft'])
self.assertEqual(len(char.spells), 1)
self.assertIsInstance(char.spells[0], spells.Druidcraft)
def test_wild_shapes(self):
char = Druid()
# Druid level 2
@@ -149,6 +195,16 @@ class TestCharacter(TestCase):
self.assertEqual(len(char.wild_shapes), 1)
self.assertIsInstance(char.wild_shapes[0], monsters.Wolf)
def test_moon_druid_wild_shapes(self):
# Moon druid level 2 gets beasts up to CR 1
char = Druid(level=2, wild_shapes=['Ape'], circle='moon')
self.assertEqual(len(char.wild_shapes), 1)
self.assertIsInstance(char.wild_shapes[0], monsters.Ape)
# Moon druid above level 6 gets beasts up to CR level / 3
char = Druid(level=9, wild_shapes=['ankylosaurus'], circle='moon')
self.assertEqual(len(char.wild_shapes), 1)
self.assertIsInstance(char.wild_shapes[0], monsters.Ankylosaurus)
def test_can_assume_shape(self):
class Beast(monsters.Monster):
description = 'beast'
@@ -188,35 +244,3 @@ class TestCharacter(TestCase):
not_beast = monsters.Monster()
not_beast.description = "monster"
self.assertFalse(low_druid.can_assume_shape(not_beast))
def test_equip_armor(self):
char = Character(dexterity=16)
char.wear_armor('leather armor')
self.assertTrue(isinstance(char.armor, Armor))
# Now make sure the armor class is correct
self.assertEqual(char.armor_class, 14)
# Try passing an Armor object directly
char.wear_armor(LeatherArmor())
self.assertEqual(char.armor_class, 14)
# Test equipped armor with max dexterity mod_str
char.armor.dexterity_mod_max = 1
self.assertEqual(char.armor_class, 12)
def test_wield_shield(self):
char = Character(dexterity=16)
char.wield_shield('shield')
self.assertTrue(isinstance(char.shield, Shield), msg=char.shield)
# Now make sure the armor class is correct
self.assertEqual(char.armor_class, 15)
# Try passing an Armor object directly
char.wield_shield(Shield)
self.assertEqual(char.armor_class, 15)
def test_speed(self):
# Check that the speed pulls from the character's race
char = Character(race='halfling')
self.assertEqual(char.speed, 25)
# Check that a character with no race defaults to 30 feet
char = Character()
char.race = None
self.assertEqual(char.speed, 30)
+17
View File
@@ -30,3 +30,20 @@ class PdfOutputTeestCase(unittest.TestCase):
char.saving_throw_proficiencies = ['strength']
make_sheets.create_character_pdf(character=char, basename=self.basename)
self.assertTrue(os.path.exists(pdf_name), f'{pdf_name} not created.')
class MarkdownTestCase(unittest.TestCase):
"""Check that conversion of markdown formats to LaTeX code works
correctly."""
def test_rst_bold(self):
text = make_sheets.rst_to_latex('**hello**')
self.assertEqual(text, '\\textbf{hello}')
def test_hit_dice(self):
text = make_sheets.rst_to_latex('1d6+3')
self.assertEqual(text, '\\texttt{1d6+3}')
def test_no_text(self):
text = make_sheets.rst_to_latex(None)
self.assertEqual(text, '')