예제 #1
0
    def test_attack_dead_unit(self):
        jack = Unit('Jack', 100, 20)
        bob = Unit('Bob', 100, 33)

        jack.take_damage(100)

        with self.assertRaises(UnitIsDead):
            bob.attack(jack)
예제 #2
0
    def test_add_hit_points(self):
        jack = Unit('Jack', 100, 20)

        jack.take_damage(50)

        self.assertEqual(jack.hit_points, 50)

        jack.add_hit_points(50)

        self.assertEqual(jack.hit_points, 100)

        jack.take_damage(100)

        with self.assertRaises(UnitIsDead):
            jack.add_hit_points(100)
예제 #3
0
 def test_take_damage_more_damage_than_hp_should_return_0(self):
     npc = Unit(health=20, mana=50)
     npc.take_damage(30)
     self.assertEqual(npc.get_health(), 0)