def test_when_hero_has_no_weapons_then_return_none(self):
        test_obj = Hero(name="Bron",
                        title="Dragonslayer",
                        health=100,
                        mana=100,
                        mana_regeneration_rate=2)

        self.assertEqual(test_obj.attack(by='weapon'), None)
        self.assertEqual(test_obj.attack(by='magic'), None)
        self.assertEqual(test_obj.attack(), None)
    def test_when_unrecognise_means_then_raises_value_error(self):
        test_obj = Hero(name="Bron",
                        title="Dragonslayer",
                        health=100,
                        mana=100,
                        mana_regeneration_rate=2)

        with self.assertRaisesRegex(ValueError,
                                    'Unrecognized means of attack.'):
            test_obj.attack(by='testing')
    def test_when_hero_wants_to_attack_with_magic_and_has_it_but_has_no_mana_then_return_none(
            self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        spell = Spell(name="Fireball", damage=30, mana_cost=150, cast_range=2)

        spell.equip_to(hero)

        self.assertEqual(hero.attack(by='magic'), None)
    def test_when_hero_wants_to_attack_with_weapon_and_has_it_then_return_weapon(
            self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        weapon = Weapon(name="The Axe of Destiny", damage=20)

        weapon.equip_to(hero)

        self.assertEqual(hero.attack(by='weapon'), weapon)
    def test_when_hero_wants_to_attack_with_magic_and_has_and_can_cast_spell_then_return_spell(
            self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        spell = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)

        spell.equip_to(hero)

        self.assertEqual(hero.attack(by='magic'), spell)
        self.assertEqual(getattr(hero, 'mana'), 50)