예제 #1
0
 def test_wield_weapon(self):
     char = Character()
     char.strength = 14
     char.weapon_proficiencies = [Shortsword]
     # Add a weapon
     char.wield_weapon('shortsword')
     self.assertEqual(len(char.weapons), 1)
     sword = char.weapons[0]
     self.assertTrue(isinstance(sword, Weapon))
     self.assertTrue(isinstance(sword, Shortsword))
     self.assertEqual(sword.attack_modifier, 4) # str + prof
     self.assertEqual(sword.damage, '1d6+2') # str
     # Check if dexterity is used if it's higher (Finesse weapon)
     char.weapons = []
     char.dexterity = 16
     char.wield_weapon('shortsword')
     sword = char.weapons[0]
     self.assertEqual(sword.attack_modifier, 5) # dex + prof
     # Check if race weapon proficiencies are considered
     char.weapons = []
     char.weapon_proficiencies = []
     char.race = race.HighElf()
     char.wield_weapon('shortsword')
     sword = char.weapons[0]
     self.assertEqual(sword.attack_modifier, 5)
예제 #2
0
 def test_speed(self):
     # Check that the speed pulls from the character's race
     char = Character(race='lightfoot halfling')
     self.assertEqual(char.speed, '25')
     # Check that a character with no race defaults to 30 feet
     char = Character()
     char.race = None
     self.assertEqual(char.speed, '30')
예제 #3
0
 def test_proficiencies_text(self):
     char = Character()
     char._proficiencies_text = ('hello', 'world')
     self.assertEqual(char.proficiencies_text, 'Hello, world.')
     # Check for extra proficiencies
     char.proficiencies_extra = ("it's", "me")
     self.assertEqual(char.proficiencies_text, "Hello, world, it's, me.")
     # Check that race proficienceis are included
     elf = race.HighElf()
     char.race = elf
     expected = "Hello, world, longswords, shortswords, shortbows, longbows, it's, me."
     self.assertEqual(char.proficiencies_text, expected)
예제 #4
0
 def test_is_proficient(self):
     char = Character(classes=['Wizard'])
     char.weapon_proficiencies
     sword = Shortsword()
     # Check for not-proficient weapon
     self.assertFalse(char.is_proficient(sword))
     # Check if we're proficient in the weapon
     char.weapon_proficiencies = [Shortsword]
     self.assertTrue(char.is_proficient(sword))
     # Now try it with a racial proficiency
     char.weapon_proficiencies = tuple()
     char.race = race.HighElf()
     self.assertTrue(char.is_proficient(sword))
예제 #5
0
 def test_proficiencies_text(self):
     char = Character()
     char._proficiencies_text = ('hello', 'world')
     self.assertIn('hello', char.proficiencies_text.lower())
     self.assertIn('world', char.proficiencies_text.lower())
     # Check for extra proficiencies
     char._proficiencies_text += ("it's", "me")
     self.assertIn("it's", char.proficiencies_text.lower())
     self.assertIn('me', char.proficiencies_text.lower())
     # Check that race proficienceis are included
     elf = race.HighElf()
     char.race = elf
     expected = ("hello", "world", "longswords", "shortswords", "shortbows",
                 "longbows", "it's", "me")
     for e in expected:
         self.assertIn(e, char.proficiencies_text.lower())