diff --git a/dungeonsheets/spells/spells.py b/dungeonsheets/spells/spells.py index 4b36c40..8e3731d 100644 --- a/dungeonsheets/spells/spells.py +++ b/dungeonsheets/spells/spells.py @@ -47,19 +47,17 @@ class Spell: classes = () def __str__(self): - if len(self.components) == 0: - s = self.name - else: - s = self.name + " ({:s}) ".format(",".join(self.components)) + s = self.name + requirements = list(self.components) # Indicate if this is a ritual or a concentration indicators = [ ("R", self.ritual), ("C", self.concentration), ("$", self.special_material), ] - indicators = tuple(letter for letter, is_active in indicators if is_active) - if len(indicators): - s += f' ({", ".join(indicators)})' + requirements.extend([letter for letter, is_active in indicators if is_active]) + if len(requirements): + s += f' ({"/".join(requirements)})' return s def __repr__(self): @@ -88,4 +86,4 @@ class Spell: @property def special_material(self): - return "worth at least" in self.materials.lower() + return "worth" in self.materials.lower() diff --git a/tests/test_spells.py b/tests/test_spells.py index 9e92a72..9996bcb 100644 --- a/tests/test_spells.py +++ b/tests/test_spells.py @@ -41,8 +41,17 @@ class TestSpells(TestCase): self.assertEqual(str(spell), "My spell (R)") # Try with a ritual and a concentration spell.concentration = True - self.assertEqual(str(spell), "My spell (R, C)") + self.assertEqual(str(spell), "My spell (R/C)") # Try with ritual/concentration/verbal/somatic - # spell. - # self.assertEqual(str(spell), "My spell (R, C)") + spell.components = ("V", "S") + self.assertEqual(str(spell), "My spell (V/S/R/C)") # # Try with material components with a cost + spell.components = ("V", "S", "M") + spell.materials = "A stone worth 50 GP" + self.assertEqual(str(spell), "My spell (V/S/M/R/C/$)") + + def test_special_material(self): + spell = Spell() + # From revivify + spell.materials = "Diamonds worth 300 gp, which the spell consumes" + self.assertTrue(spell.special_material)