コード例 #1
0
    def test_learn_spell_when_hero_has_enough_mana_returns_heros_spell(self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)

        hero.learn(s)
        heros_spell = hero.spell

        self.assertEqual(heros_spell, s)
コード例 #2
0
    def test_learn_more_spells_when_hero_has_enough_mana_returns_heros_spell_equal_to_the_last_one(
            self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        s1 = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)
        s2 = Spell(name="Fireballs", damage=40, mana_cost=30, cast_range=2)

        hero.learn(s1)
        hero.learn(s2)
        heros_spell = hero.spell

        self.assertEqual(heros_spell, s2)
コード例 #3
0
 def test_fight_spell_weapon(self):
     hero = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)
     w = Weapon(name="The Axe of Destiny", damage=20)
     hero.equip(w)
     enemy = Enemy(100, 100, 20)
     hero.location = [0, 0]
     enemy.location = [2, 0]
     s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)
     hero.learn(s)
     f = Fight(hero, enemy)
     print("\ntest hero weapon spell\n")
     f.mortal_kombat()
     self.assertEqual(f.return_hero().health, 80)
コード例 #4
0
    def test_learn_spell_when_hero_does_not_have_enough_mana_raise_an_error(
            self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=20,
                    mana_regeneration_rate=2)
        s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)

        exc = None
        try:
            hero.learn(s)
        except Exception as err:
            exc = err

        self.assertIsNotNone(str(exc))
        self.assertEqual(str(exc), 'Cannot cast that spell')