Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
    def _apply_damage_absorption(self, damage: Damage, to_print=False) -> Damage:
        """
        This method subtracts the absorption (if any) from the damage
        :param to_print: A boolean indicating if we want to actually subtract the damage from the shield. If it's true,
        we're getting the damage for the sole reason to print it only, therefore we should not modify anything
        :return Damage
        """

        if self.absorption_shield:  # if there is anything to absorb
            # lowers the damage and returns our shield
            if not to_print:  # we want to modify the shield
                self.absorption_shield = damage.handle_absorption(self.absorption_shield)
            else:
                damage.handle_absorption(self.absorption_shield) # only modify the specific damage in order to print it

        return damage
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
0
    def _apply_damage_absorption(self,
                                 damage: Damage,
                                 to_print=False) -> Damage:
        """
        This method subtracts the absorption (if any) from the damage
        :param to_print: A boolean indicating if we want to actually subtract the damage from the shield. If it's true,
        we're getting the damage for the sole reason to print it only, therefore we should not modify anything
        :return Damage
        """

        if self.absorption_shield:  # if there is anything to absorb
            # lowers the damage and returns our shield
            if not to_print:  # we want to modify the shield
                self.absorption_shield = damage.handle_absorption(
                    self.absorption_shield)
            else:
                damage.handle_absorption(
                    self.absorption_shield
                )  # only modify the specific damage in order to print it

        return damage