Esempio n. 1
0
    def test_equip_with_more_weapons_returns_last_weapon(self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        w1 = Weapon(name="The Axe of Destiny", damage=20)
        w2 = Weapon(name="The sword of Destiny", damage=30)

        hero.equip(w1)
        hero.equip(w2)

        heros_weapon = hero.weapon

        self.assertEqual(heros_weapon, w2)
Esempio n. 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)
Esempio n. 3
0
    def test_equip_hero_with_a_weapon_returns_heros_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)

        heros_weapon = hero.weapon

        self.assertEqual(heros_weapon, w)
Esempio n. 4
0
 def test_fight_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, 1]
     f = Fight(hero, enemy)
     print("\ntest only weapon\n")
     f.mortal_kombat()
     self.assertEqual(f.return_hero().health, 20)
Esempio n. 5
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)
Esempio n. 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
Esempio n. 7
0
    pygame.display.update()

    time.sleep(5)
    pygame.quit()
    quit()


map = Dungeon("level1.txt")

h = Hero(name="Bron",
         title="Dragonslayer",
         health=100,
         mana=100,
         mana_regeneration_rate=2)
w = Weapon(name="The Axe of Destiny", damage=20)
# s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=200)

h.equip(w)
# h.learn(s)

pygame.init()

white_hero = (255, 255, 255)
black_enemy = (0, 0, 0)
red_treasure = (255, 92, 51)
gray_wall = (128, 64, 0)

dis = pygame.display.set_mode((1000, 500))

pygame.display.set_caption('Dungeons And Pythons')