Ejemplo n.º 1
0
    def test_learn_spell_hero_spell_must_be_the_spell(self):
        h = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)

        spell = Spell(name='Fireball', damage=20, mana_cost=20, cast_range=2)
        h.learn(spell)

        self.assertEqual(h.spell, spell)
Ejemplo n.º 2
0
    def test_attack_method_when_by_spell_when_has_spell(self):
        h = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)
        spell = Spell(name='Fireball', damage=20, mana_cost=20, cast_range=2)
        h.learn(spell)

        result = h.attack(by='spell')

        self.assertEqual(result, 20)
Ejemplo n.º 3
0
    def test_can_cast_function_should_return_true_if_object_can_cast(self):
        h = Hero(name="Bron",
                 title="Dragonslayer",
                 health=100,
                 mana=100,
                 mana_regeneration_rate=2)
        s = Spell(name='Fireball', damage=20, mana_cost=20, cast_range=2)

        h.learn(s)

        result = Mixin.can_cast(h)

        self.assertTrue(result)
    def test_init_fight_should_save_hero_and_enemy(self):
        map_ = Dungeon('level1.txt')
        hero = Hero(name="Bron",
                    title="Dragonslayer",
                    health=100,
                    mana=100,
                    mana_regeneration_rate=2)
        weapon = Weapon('Axe', 20)
        spell = Spell('Fireball', 20, 50, 2)
        hero.equip(weapon)
        hero.learn(spell)
        enemy = Enemy(health=100, mana=20, damage=20)

        fight = Fight(hero, enemy, level_map=map_.level_map)

        self.assertEqual((hero, enemy), (fight.hero, fight.enemy))