예제 #1
0
    def test_str_only_mag_dmg_with_absorbed(self):
        expected_magic = 10.10
        expected_absorbed = 10
        dmg = Damage(magic_dmg=10.111)
        dmg.magic_absorbed = expected_absorbed
        expected_str = f'{expected_magic:.2f} magical damage ({expected_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #2
0
    def test_str_only_mag_dmg_with_absorbed(self):
        expected_magic = 10.10
        expected_absorbed = 10
        dmg = Damage(magic_dmg=10.111)
        dmg.magic_absorbed = expected_absorbed
        expected_str = f'{expected_magic:.2f} magical damage ({expected_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #3
0
    def test_str_with_phys_dmg_magic_absorbed(self):
        expected_phys = 10.2
        expected_magic = 0
        expected_magic_absorbed = 5.5
        dmg = Damage(phys_dmg=10.199)
        dmg.magic_absorbed = expected_magic_absorbed
        expected_str = f'{expected_phys:.2f} physical damage and {expected_magic:.2f} magical damage ({expected_magic_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #4
0
    def test_str_with_phys_dmg_magic_absorbed(self):
        expected_phys = 10.2
        expected_magic = 0
        expected_magic_absorbed = 5.5
        dmg = Damage(phys_dmg=10.199)
        dmg.magic_absorbed = expected_magic_absorbed
        expected_str = f'{expected_phys:.2f} physical damage and {expected_magic:.2f} magical damage ({expected_magic_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #5
0
    def test_str_with_absorbed_only(self):
        expected_magic_absorbed = 5.5
        expected_phys_absorbed = 5.4
        dmg = Damage()
        dmg.magic_absorbed = expected_magic_absorbed
        dmg.phys_absorbed = expected_phys_absorbed

        expected_str = f'0.00 physical damage ({expected_phys_absorbed:.2f} absorbed) and 0.00 magical damage ({expected_magic_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #6
0
    def test_handle_absorption_bigger_than_magic(self):
        absorption_shield = 7
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=9, magic_dmg=0)
        expected_dmg.magic_absorbed = 6
        expected_dmg.phys_absorbed = 1

        self.assertEqual(dmg, expected_dmg)
예제 #7
0
    def test_str_with_absorbed_only(self):
        expected_magic_absorbed = 5.5
        expected_phys_absorbed = 5.4
        dmg = Damage()
        dmg.magic_absorbed = expected_magic_absorbed
        dmg.phys_absorbed = expected_phys_absorbed

        expected_str = f'0.00 physical damage ({expected_phys_absorbed:.2f} absorbed) and 0.00 magical damage ({expected_magic_absorbed:.2f} absorbed)'

        self.assertEqual(str(dmg), expected_str)
예제 #8
0
    def test_handle_absorption_bigger_than_magic(self):
        absorption_shield = 7
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=9, magic_dmg=0)
        expected_dmg.magic_absorbed = 6
        expected_dmg.phys_absorbed = 1

        self.assertEqual(dmg, expected_dmg)
예제 #9
0
    def test_handle_absorption(self):
        """ The handle_absorption function subtracts the absorbed damage from the damage.
            Magical damage always gets absorbed first """
        absorption_shield = 5
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=10, magic_dmg=1)
        expected_dmg.magic_absorbed = 5

        self.assertEqual(dmg, expected_dmg)
예제 #10
0
    def test_handle_absorption(self):
        """ The handle_absorption function subtracts the absorbed damage from the damage.
            Magical damage always gets absorbed first """
        absorption_shield = 5
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=10, magic_dmg=1)
        expected_dmg.magic_absorbed = 5

        self.assertEqual(dmg, expected_dmg)
예제 #11
0
    def test_handle_absorption_bigger_than_both_dmg(self):
        absorption_shield = 17
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        left_shield = dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=0, magic_dmg=0)
        expected_dmg.magic_absorbed = 6
        expected_dmg.phys_absorbed = 10
        expected_shield = 1

        self.assertEqual(dmg, expected_dmg)
        self.assertEqual(left_shield, expected_shield)
예제 #12
0
    def test_handle_absorption_bigger_than_both_dmg(self):
        absorption_shield = 17
        dmg = Damage(phys_dmg=10, magic_dmg=6)
        left_shield = dmg.handle_absorption(absorption_shield)

        expected_dmg = Damage(phys_dmg=0, magic_dmg=0)
        expected_dmg.magic_absorbed = 6
        expected_dmg.phys_absorbed = 10
        expected_shield = 1

        self.assertEqual(dmg, expected_dmg)
        self.assertEqual(left_shield, expected_shield)