Example #1
0
    def test_known_as_with_hero_returns_string(self):
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        res = hero.known_as()

        self.assertEqual(res, 'Bron the Dragonslayer')
Example #2
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)
Example #3
0
 def test_fight_hero_naked(self):
     hero = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)
     enemy = Enemy(100, 100, 20)
     hero.location = [0, 0]
     enemy.location = [0, 2]
     f = Fight(hero, enemy)
     print("\ntest hero nothing\n")
     f.mortal_kombat()
     self.assertEqual(f.return_hero().health, 0)
Example #4
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)
Example #5
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)
Example #6
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)
Example #7
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)
Example #8
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')
Example #9
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)
    def test_move_into_treasure_which_is_health_potion_returns_heros_new_health(self):
        dungeon = Dungeon("level1.txt")
    #     # T.##.....T
    #     # ST##..###.
    #     # #.###E###E
    #     # #.E...###.
    #     # ###T#####G
        hero = Hero(name="Bron", title="Dragonslayer", health=100, mana=100, mana_regeneration_rate=2)

        dungeon.spawn(hero)
        dungeon.move_hero('Up')
        pass
Example #11
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)
Example #12
0
    TextSurf, TextRect = text_objects(text, largeText)
    TextRect.center = ((1000 / 2), (500 / 2))
    dis.blit(TextSurf, TextRect)

    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)