mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-19 04:33:26 +02:00
Monsters now have a spells attribute that will eventually hold a list of spells.
This commit is contained in:
@@ -8,7 +8,6 @@ from dungeonsheets.character import (
|
||||
Character,
|
||||
Wizard,
|
||||
Druid,
|
||||
_resolve_mechanic,
|
||||
)
|
||||
from dungeonsheets.weapons import Weapon, Shortsword
|
||||
from dungeonsheets.armor import Armor, LeatherArmor, Shield
|
||||
@@ -81,21 +80,21 @@ class TestCharacter(TestCase):
|
||||
|
||||
def test_resolve_mechanic(self):
|
||||
# Test a well defined mechanic
|
||||
NewSpell = _resolve_mechanic("mage_hand", None)
|
||||
NewSpell = Character._resolve_mechanic("mage_hand", None)
|
||||
self.assertTrue(issubclass(NewSpell, spells.Spell))
|
||||
|
||||
# Test an unknown mechanic
|
||||
def new_spell(**params):
|
||||
return spells.Spell
|
||||
|
||||
NewSpell = _resolve_mechanic("hocus_pocus", spells.Spell)
|
||||
NewSpell = Character._resolve_mechanic("hocus_pocus", spells.Spell)
|
||||
self.assertTrue(issubclass(NewSpell, spells.Spell))
|
||||
|
||||
# Test direct resolution of a proper subclass
|
||||
class MySpell(spells.Spell):
|
||||
pass
|
||||
|
||||
NewSpell = _resolve_mechanic(MySpell, spells.Spell)
|
||||
NewSpell = Character._resolve_mechanic(MySpell, spells.Spell)
|
||||
|
||||
def test_wield_weapon(self):
|
||||
char = Character()
|
||||
@@ -110,13 +109,13 @@ class TestCharacter(TestCase):
|
||||
self.assertEqual(sword.attack_modifier, 4) # str + prof
|
||||
self.assertEqual(sword.damage, "1d6+2") # str
|
||||
# Check if dexterity is used if it's higher (Finesse weapon)
|
||||
char.weapons = []
|
||||
char._weapons = []
|
||||
char.dexterity = 16
|
||||
char.wield_weapon("shortsword")
|
||||
sword = char.weapons[0]
|
||||
self.assertEqual(sword.attack_modifier, 5) # dex + prof
|
||||
# Check if race weapon proficiencies are considered
|
||||
char.weapons = []
|
||||
char._weapons = []
|
||||
char.weapon_proficiencies = []
|
||||
char.race = race.HighElf()
|
||||
char.wield_weapon("shortsword")
|
||||
|
||||
@@ -133,6 +133,7 @@ class VashtaNerada(monsters.Monster):
|
||||
saving_throws = "Dex +8"
|
||||
damage_immunities = "Bludgeoning"
|
||||
damage_resistances = "Lightning"
|
||||
damage_vulnerabilities = "Wood-based"
|
||||
challenge_rating = 93
|
||||
|
||||
|
||||
|
||||
+12
-1
@@ -1,6 +1,6 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from dungeonsheets import monsters
|
||||
from dungeonsheets import monsters, spells
|
||||
|
||||
|
||||
class AutoGeneratedMonsters(TestCase):
|
||||
@@ -351,3 +351,14 @@ class AutoGeneratedMonsters(TestCase):
|
||||
self.assertEqual(wolf.strength.value, 12)
|
||||
self.assertEqual(wolf.strength.modifier, 1)
|
||||
self.assertEqual(wolf.strength.saving_throw, 1)
|
||||
|
||||
class MonsterSpellcastingTests(TestCase):
|
||||
def test_spells(self):
|
||||
# Check that monster spells can be set, and then resolved to real spell objects
|
||||
class MyMonster(monsters.Monster):
|
||||
spells = ["cure wounds", spells.Bane]
|
||||
|
||||
self.assertIsInstance(MyMonster.spells[0], type,
|
||||
msg="Monster spell is not a class")
|
||||
self.assertTrue(issubclass(MyMonster.spells[0], spells.Spell))
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class Roll20ReaderTests(unittest.TestCase):
|
||||
"warhammer",
|
||||
"unarmed strike",
|
||||
],
|
||||
_proficiencies_text=[
|
||||
proficiencies_text=[
|
||||
"Brewer's Supplies",
|
||||
],
|
||||
languages="common, dwarvish",
|
||||
@@ -204,7 +204,7 @@ class FoundryReaderTests(unittest.TestCase):
|
||||
"crossbow",
|
||||
"knives",
|
||||
],
|
||||
_proficiencies_text=[
|
||||
proficiencies_text=[
|
||||
"artisan's tools",
|
||||
"disguise kit",
|
||||
"forger's kit",
|
||||
|
||||
Reference in New Issue
Block a user