mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-19 04:33:26 +02:00
added features and multiclass tests
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from dungeonsheets.features import create_feature, Feature
|
||||
|
||||
|
||||
class TestFeatures(TestCase):
|
||||
"""Tests for features and feature-related activities."""
|
||||
|
||||
def test_create_feature(self):
|
||||
NewFeature = create_feature(name="Hello world")
|
||||
self.assertTrue(issubclass(NewFeature, Feature))
|
||||
self.assertEqual(NewFeature.name, 'Hello world')
|
||||
feature = NewFeature()
|
||||
print(feature, feature.__class__, type(feature))
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from unittest import TestCase
|
||||
import warnings
|
||||
|
||||
from dungeonsheets import race, monsters, exceptions, spells
|
||||
from dungeonsheets.character import Character
|
||||
from dungeonsheets.weapons import Weapon, Shortsword
|
||||
from dungeonsheets.armor import Armor, LeatherArmor, Shield
|
||||
|
||||
|
||||
class TestMulticlass(TestCase):
|
||||
"""
|
||||
Tests for Multiclass character.
|
||||
"""
|
||||
def test_constructor(self):
|
||||
char = Character(name='Multiclass',
|
||||
classes=['wizard', 'fighter'],
|
||||
levels=[5, 4])
|
||||
|
||||
def test_level(self):
|
||||
char = Character(name='Multiclass',
|
||||
classes=['wizard', 'fighter'],
|
||||
levels=[5, 4])
|
||||
self.assertEqual(char.level, 9)
|
||||
|
||||
def test_spellcasting(self):
|
||||
char = Character(name='Multiclass',
|
||||
classes=['wizard', 'fighter'],
|
||||
levels=[5, 4])
|
||||
self.assertEqual(len(char.spellcasting_classes), 1)
|
||||
char = Character(name='Multiclass',
|
||||
classes=['wizard', 'fighter'],
|
||||
subclasses=[None, 'Eldritch Knight'],
|
||||
levels=[5, 4])
|
||||
self.assertEqual(len(char.spellcasting_classes), 2)
|
||||
# equivalent spellcasting level: 6
|
||||
self.assertEqual(char.spell_slots(spell_level=1), 4)
|
||||
self.assertEqual(char.spell_slots(spell_level=2), 3)
|
||||
self.assertEqual(char.spell_slots(spell_level=3), 3)
|
||||
self.assertEqual(char.spell_slots(spell_level=4), 0)
|
||||
|
||||
def test_proficiencies(self):
|
||||
char1 = Character(name='Multiclass',
|
||||
classes=['wizard', 'fighter'],
|
||||
levels=[5, 4])
|
||||
for svt in ('intelligence', 'wisdom'):
|
||||
self.assertIn(svt, char1.saving_throw_proficiencies)
|
||||
char2 = Character(name='Multiclass',
|
||||
classes=['wizard', 'rogue'],
|
||||
levels=[5, 4])
|
||||
char3 = Character(name='Multiclass',
|
||||
classes=['rogue', 'wizard'],
|
||||
levels=[4, 5])
|
||||
sword = Shortsword()
|
||||
self.assertTrue(char1.is_proficient(sword))
|
||||
# multiclassing into Rogue doesn't give simple weapon proficiency
|
||||
self.assertFalse(char2.is_proficient(sword))
|
||||
self.assertTrue(char3.is_proficient(sword))
|
||||
|
||||
@@ -2,6 +2,7 @@ import unittest
|
||||
|
||||
from dungeonsheets.weapons import Weapon
|
||||
|
||||
|
||||
class WeaponTestCase(unittest.TestCase):
|
||||
def test_weapon_damage(self):
|
||||
weapon = Weapon()
|
||||
@@ -9,4 +10,4 @@ class WeaponTestCase(unittest.TestCase):
|
||||
self.assertEqual(weapon.damage, '1d6')
|
||||
# Now add some bonus damage
|
||||
weapon.bonus_damage = 2
|
||||
self.assertEqual(weapon.damage, '1d6 +2')
|
||||
self.assertEqual(weapon.damage, '1d6+2')
|
||||
|
||||
Reference in New Issue
Block a user