Esempio n. 1
0
 def test_moon_druid_wild_shapes(self):
     # Moon druid level 2 gets beasts up to CR 1
     char = Druid(level=2, wild_shapes=['Ape'], circle='moon')
     self.assertEqual(len(char.wild_shapes), 1)
     self.assertIsInstance(char.wild_shapes[0], monsters.Ape)
     # Moon druid above level 6 gets beasts up to CR level / 3
     char = Druid(level=9, wild_shapes=['ankylosaurus'], circle='moon')
     self.assertEqual(len(char.wild_shapes), 1)
     self.assertIsInstance(char.wild_shapes[0], monsters.Ankylosaurus)
Esempio n. 2
0
 def test_learned_spells(self):
     """For a druid, learning spells is not necessary and this field should
     be ignored."""
     char = Druid()
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", message="Druids cannot learn spells")
         char.set_attrs(spells=["invisibility"], spells_prepared=["druidcraft"])
     # self.assertEqual(len(char.spells), 1)
     self.assertEqual(len(char.spells), 2)
     self.assertIn(spells.Druidcraft(), char.spells)
 def test_learned_spells(self):
     """For a druid, learning spells is not necessary and this field should
     be ignored."""
     char = Druid()
     with warnings.catch_warnings():
         warnings.filterwarnings('ignore',
                                 message="Druids cannot learn spells")
         char.set_attrs(spells=['invisibility'],
                        spells_prepared=['druidcraft'])
     self.assertEqual(len(char.spells), 1)
     self.assertIsInstance(char.spells[0], spells.Druidcraft)
Esempio n. 4
0
 def test_wild_shapes(self):
     char = Druid()
     # Druid level 2
     char.level = 2
     # Set reasonable wild shapes
     char.wild_shapes = ['Wolf']
     self.assertIsInstance(char.wild_shapes[0], monsters.Wolf)
     # Check what happens if a non-existent wild_shape is added
     with self.assertRaises(exceptions.MonsterError):
         char.wild_shapes = ['Wolf', 'Hyperion Loader']
     # Check what happens if a valid monster class is directly added
     char.wild_shapes = [monsters.Wolf(), ]
     self.assertIsInstance(char.wild_shapes[0], monsters.Wolf)
     # Check that invalid monsters aren't accepted
     char.wild_shapes = ['Wolf', 'giant eagle']
     self.assertEqual(len(char.wild_shapes), 1)
     self.assertIsInstance(char.wild_shapes[0], monsters.Wolf)
Esempio n. 5
0
 def test_can_assume_shape(self):
     class Beast(monsters.Monster):
         description = 'beast'
     new_druid = Druid(level=1)
     low_druid = Druid(level=2)
     mid_druid = Druid(level=4)
     high_druid = Druid(level=8)
     beast = Beast()
     # Check that level 1 druid automatically fails
     self.assertFalse(new_druid.can_assume_shape(beast))
     # Check if a basic beast can be transformed
     self.assertTrue(low_druid.can_assume_shape(beast))
     # Check that challenge rating is checked
     hard_beast = Beast()
     hard_beast.challenge_rating = 1/2
     really_hard_beast = Beast()
     really_hard_beast.challenge_rating = 1
     self.assertFalse(low_druid.can_assume_shape(hard_beast))
     self.assertFalse(low_druid.can_assume_shape(really_hard_beast))
     self.assertTrue(mid_druid.can_assume_shape(hard_beast))
     self.assertFalse(mid_druid.can_assume_shape(really_hard_beast))
     self.assertTrue(high_druid.can_assume_shape(hard_beast))
     self.assertTrue(high_druid.can_assume_shape(really_hard_beast))
     # Check that swim speed is enforced
     swim_beast = Beast()
     swim_beast.swim_speed = 15
     self.assertFalse(low_druid.can_assume_shape(swim_beast))
     self.assertTrue(mid_druid.can_assume_shape(swim_beast))
     self.assertTrue(high_druid.can_assume_shape(swim_beast))
     # Check that fly speed is enforced
     fly_beast = Beast()
     fly_beast.fly_speed = 15
     self.assertFalse(low_druid.can_assume_shape(fly_beast))
     self.assertFalse(mid_druid.can_assume_shape(fly_beast))
     self.assertTrue(high_druid.can_assume_shape(fly_beast))
     # Check that non-beasts are not allowed
     not_beast = monsters.Monster()
     not_beast.description = "monster"
     self.assertFalse(low_druid.can_assume_shape(not_beast))