mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-18 20:23:27 +02:00
Added tests for dice and equpment parser
This commit is contained in:
@@ -234,6 +234,27 @@ class TestCharacter(TestCase):
|
||||
char.wield_shield(Shield)
|
||||
self.assertEqual(char.armor_class, 15)
|
||||
|
||||
def test_carrying_weight(self):
|
||||
char = Character(race="lightfoot halfling", strength=12)
|
||||
# Check carrying capacity
|
||||
self.assertEqual(char.carrying_capacity, 180)
|
||||
# Check the armor weight is included
|
||||
char.wear_armor(LeatherArmor())
|
||||
self.assertEqual(char.carrying_weight, 10)
|
||||
# Check the shield weight is included
|
||||
char = Character()
|
||||
char.wield_shield("shield")
|
||||
self.assertEqual(char.carrying_weight, 6)
|
||||
# Check the weight weapons at hand are included
|
||||
char = Character()
|
||||
char.wield_weapon("shortsword")
|
||||
char.wield_weapon("dagger")
|
||||
self.assertEqual(char.carrying_weight, 3)
|
||||
# Check the listed equipment is included
|
||||
char = Character()
|
||||
char.equipment = "blanket, crowbar"
|
||||
self.assertEqual(char.carrying_weight, 8)
|
||||
|
||||
def test_speed(self):
|
||||
# Check that the speed pulls from the character's race
|
||||
char = Character(race="lightfoot halfling")
|
||||
|
||||
@@ -15,6 +15,11 @@ class TestDice(TestCase):
|
||||
out = dice.read_dice_str("15d10")
|
||||
self.assertEqual(out.faces, 10)
|
||||
self.assertEqual(out.num, 15)
|
||||
# Modifier
|
||||
out = dice.read_dice_str("2d20 + 5")
|
||||
self.assertEqual(out.faces, 20)
|
||||
self.assertEqual(out.num, 2)
|
||||
self.assertEqual(out.modifier, 5)
|
||||
# Check a bad value
|
||||
with self.assertRaises(DiceError):
|
||||
dice.read_dice_str("Ed15")
|
||||
@@ -23,6 +28,19 @@ class TestDice(TestCase):
|
||||
self.assertEqual(dice.combine_dice("1d8 + 6 + 2d8 + 12"), "3d8 + 18")
|
||||
self.assertEqual(dice.combine_dice("1d8 + 1d5 + 2d8 + 1d5"), "2d5 + 3d8")
|
||||
|
||||
def test_dice_mean(self):
|
||||
dd = dice.read_dice_str("1d10")
|
||||
dd_mean = dice._dice_mean(dd)
|
||||
self.assertEqual(dd_mean, 5.5)
|
||||
dd = dice.read_dice_str("2d20+4")
|
||||
dd_mean = dice._dice_mean(dd)
|
||||
self.assertEqual(dd_mean, 25)
|
||||
|
||||
def test_dice_roll_mean(self):
|
||||
dd_mean = dice.dice_roll_mean("1d6")
|
||||
self.assertEqual(dd_mean, 4)
|
||||
dd_mean = dice.dice_roll_mean("2d20+2")
|
||||
self.assertEqual(dd_mean, 23)
|
||||
|
||||
def test_simple_rolling(self):
|
||||
num_tests = 100
|
||||
|
||||
Reference in New Issue
Block a user