def test_homebrew_spells(self): char = Character() class MySpell(spells.Spell): name="my spell!" char.set_attrs(spells=(MySpell,)) self.assertIsInstance(char.spells[0], spells.Spell) self.assertEqual(char.spells[0].name, "my spell!")
def test_homebrew_infusions(self): char = Character(classes="artificer") class MyInfusion(infusions.Infusion): name="my infusion!" # Pass an already created infusion class char.set_attrs(infusions=(MyInfusion,)) self.assertIsInstance(char.infusions[0], infusions.Infusion) self.assertEqual(char.infusions[0].name, "my infusion!") # Pass a previously undefined infusion 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")
def test_set_attrs(self): char = Character() char.set_attrs(name='Inara') self.assertEqual(char.name, 'Inara') # Check that the weapons get loaded as objects not string char.set_attrs(weapons=['shortsword']) self.assertEqual(len(char.weapons), 1) self.assertTrue(isinstance(char.weapons[0], Shortsword)) # Check that armor and shield gets set_attrs char.set_attrs(armor='light leather armor', shield='shield') self.assertFalse(isinstance(char.armor, str)) self.assertFalse(isinstance(char.shield, str)) # Check that race gets set to an object char.set_attrs(race='high elf') self.assertIsInstance(char.race, race.HighElf)
def test_set_attrs(self): char = Character() char.set_attrs(name="Inara") self.assertEqual(char.name, "Inara") # Check that the weapons get loaded as objects not string char.set_attrs(weapons=["shortsword"]) self.assertEqual(len(char.weapons), 1) self.assertTrue(isinstance(char.weapons[0], Shortsword)) # Check that armor and shield gets set_attrs char.set_attrs(armor="leather armor", shield="shield") self.assertFalse(isinstance(char.armor, str)) self.assertFalse(isinstance(char.shield, str)) # Check that race gets set to an object char.set_attrs(race="high elf") self.assertIsInstance(char.race, race.HighElf) # Check inspiration works char.set_attrs(inspiration=True) self.assertTrue(char.inspiration) char.set_attrs(inspiration=False) self.assertFalse(char.inspiration)