mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-07 13:15:53 +02:00
Fix failing character.py tests
This commit is contained in:
@@ -163,7 +163,7 @@ class Character(Entity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
class_list: Sequence = [],
|
||||
classes: Sequence = [],
|
||||
levels: Sequence[int] = [],
|
||||
subclasses: Sequence = [],
|
||||
**attrs,
|
||||
@@ -175,7 +175,7 @@ class Character(Entity):
|
||||
|
||||
Parameters
|
||||
==========
|
||||
class_list
|
||||
classes
|
||||
Strings with class names, or character class definitions
|
||||
representing the characters various D&D classes.
|
||||
levels
|
||||
@@ -191,7 +191,7 @@ class Character(Entity):
|
||||
super(Character, self).__init__()
|
||||
self.clear()
|
||||
# make sure class, race, background are set first
|
||||
my_classes = class_list
|
||||
my_classes = classes
|
||||
my_levels = levels
|
||||
my_subclasses = subclasses
|
||||
# backwards compatability
|
||||
@@ -219,7 +219,7 @@ class Character(Entity):
|
||||
self.__set_max_hp(attrs.get("hp_max", None))
|
||||
|
||||
def clear(self):
|
||||
# reset class-definied items
|
||||
# reset class-defined items
|
||||
self.class_list = list()
|
||||
self.weapons = list()
|
||||
self.magic_items = list()
|
||||
|
||||
@@ -64,7 +64,7 @@ class TestCharacter(TestCase):
|
||||
self.assertEqual(char.spells[0].name, "my spell!")
|
||||
|
||||
def test_homebrew_infusions(self):
|
||||
char = Character(class_list="artificer")
|
||||
char = Character(classes="artificer")
|
||||
|
||||
class MyInfusion(infusions.Infusion):
|
||||
name = "my infusion!"
|
||||
@@ -74,7 +74,7 @@ class TestCharacter(TestCase):
|
||||
self.assertIsInstance(char.infusions[0], infusions.Infusion)
|
||||
self.assertEqual(char.infusions[0].name, "my infusion!")
|
||||
# Pass a previously undefined infusion
|
||||
char = Character(class_list="artificer")
|
||||
char = Character(classes="artificer")
|
||||
char.set_attrs(infusions=("spam_infusion",))
|
||||
self.assertIsInstance(char.infusions[0], infusions.Infusion)
|
||||
self.assertEqual(char.infusions[0].name, "Spam Infusion")
|
||||
@@ -129,7 +129,7 @@ class TestCharacter(TestCase):
|
||||
self.assertEqual(repr(char), "<Wizard: Inara>")
|
||||
|
||||
def test_is_proficient(self):
|
||||
char = Character(class_list=["Wizard"])
|
||||
char = Character(classes=["Wizard"])
|
||||
char.weapon_proficiencies
|
||||
sword = Shortsword()
|
||||
# Check for not-proficient weapon
|
||||
|
||||
@@ -13,24 +13,24 @@ class TestMulticlass(TestCase):
|
||||
|
||||
def test_constructor(self):
|
||||
char = Character(
|
||||
name="Multiclass", class_list=["wizard", "fighter"], levels=[5, 4]
|
||||
name="Multiclass", classes=["wizard", "fighter"], levels=[5, 4]
|
||||
)
|
||||
self.assertIsInstance(char, Character)
|
||||
|
||||
def test_level(self):
|
||||
char = Character(
|
||||
name="Multiclass", class_list=["wizard", "fighter"], levels=[5, 4]
|
||||
name="Multiclass", classes=["wizard", "fighter"], levels=[5, 4]
|
||||
)
|
||||
self.assertEqual(char.level, 9)
|
||||
|
||||
def test_spellcasting(self):
|
||||
char = Character(
|
||||
name="Multiclass", class_list=["wizard", "fighter"], levels=[5, 4]
|
||||
name="Multiclass", classes=["wizard", "fighter"], levels=[5, 4]
|
||||
)
|
||||
self.assertEqual(len(char.spellcasting_classes), 1)
|
||||
char = Character(
|
||||
name="Multiclass",
|
||||
class_list=["wizard", "fighter"],
|
||||
classes=["wizard", "fighter"],
|
||||
subclasses=[None, "Eldritch Knight"],
|
||||
levels=[5, 4],
|
||||
)
|
||||
@@ -43,12 +43,12 @@ class TestMulticlass(TestCase):
|
||||
|
||||
def test_proficiencies(self):
|
||||
char1 = Character(
|
||||
name="Multiclass", class_list=["wizard", "fighter"], levels=[5, 4]
|
||||
name="Multiclass", classes=["wizard", "fighter"], levels=[5, 4]
|
||||
)
|
||||
for svt in ("intelligence", "wisdom"):
|
||||
self.assertIn(svt, char1.saving_throw_proficiencies)
|
||||
char2 = Character(name="Multiclass", class_list=["wizard", "rogue"], levels=[5, 4])
|
||||
char3 = Character(name="Multiclass", class_list=["rogue", "wizard"], levels=[4, 5])
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user