예제 #1
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)
예제 #2
0
 def test_fight_spell_enemy_hero_none(self):
     hero = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)
     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)
     s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)
     # hero.learn(s)
     enemy = Enemy(100, 100, 20)
     enemy = Enemy(200, 100, 20)
     enemy = Enemy(130, 100, 20)
     enemy.learn(s)
     hero.location = [0, 0]
     enemy.location = [0, 2]
     f = Fight(hero, enemy)
     print("\ntest hero no spell enime has \n")
     f.mortal_kombat()
     self.assertEqual(f.return_hero().health, 0)
예제 #3
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)
예제 #4
0
 def test_fight_direct_spell_weak(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 = [0, 0]
     s = Spell(name="Fireball", damage=10, mana_cost=50, cast_range=2)
     hero.learn(s)
     f = Fight(hero, enemy)
     print("\ntest hero fight one over the other\n")
     f.mortal_kombat()
     self.assertEqual(f.return_hero().health, 20)
예제 #5
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')
예제 #6
0
def convert_treasures_as_instance(dict_with_treasures):
    list_with_instance = []

    for key, value in dict_with_treasures.items():
        if key == 'potion':
            for potion in value:
                if 'health' in potion:
                    list_with_instance.append(Potion(potion='health', points=potion['health']))
                elif 'mana' in potion:
                    list_with_instance.append(Potion(potion='mana', points=potion['mana']))

        elif key == 'spell':
            for spell in value:
                list_with_instance.append(Spell(name=spell['name'], damage=spell['damage'], mana_cost=spell['mana_cost'], cast_range=spell['cast_range']))

        elif key == 'weapon':
            for weapon in value:
                list_with_instance.append(Weapon(name=weapon['name'], damage=weapon['damage']))

    return list_with_instance