当前位置: 首页>>代码示例>>Python>>正文


Python Enemy.take_healing方法代码示例

本文整理汇总了Python中enemy.Enemy.take_healing方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.take_healing方法的具体用法?Python Enemy.take_healing怎么用?Python Enemy.take_healing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在enemy.Enemy的用法示例。


在下文中一共展示了Enemy.take_healing方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestEnemy

# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_healing [as 别名]
class TestEnemy(unittest.TestCase):
    def setUp(self):
        self.enemy = Enemy(200, 300, 50)

    def test_enemy_init(self):
        self.assertEqual(self.enemy.health, 200)
        self.assertEqual(self.enemy.mana, 300)

        self.assertEqual(self.enemy.curr_mana, self.enemy.mana)
        self.assertEqual(self.enemy.curr_health, self.enemy.health)

    def test_enemy_is_alive(self):
        self.enemy.curr_health = 30
        self.assertTrue(self.enemy.is_alive())

        self.enemy.curr_health = 0
        self.assertFalse(self.enemy.is_alive())

    def test_enemy_can_cast(self):
        s = Spell("BatkaAttack", 30, 50, 2)
        self.assertTrue(self.enemy.can_cast(s))
        self.assertEqual(self.enemy.curr_mana, 250)

        s1 = Spell("MegaBatkaAttack", 30, 350, 2)
        self.assertRaises(Exception)

    def test_enemy_take_damage(self):
        self.enemy.take_damage(50)
        self.assertEqual(self.enemy.curr_health, 150)

        self.enemy.take_damage(1000)
        self.assertEqual(self.enemy.curr_health, 0)

    def test_enemy_take_healing(self):
        self.assertFalse(self.enemy.take_healing(20))

        self.enemy.take_damage(100)
        self.assertTrue(self.enemy.take_healing(20))
        self.assertEqual(self.enemy.curr_health, 120)

        self.enemy.curr_health = 0
        self.assertFalse(self.enemy.take_healing(20))

    def test_enemy_attack(self):
        self.assertEqual(self.enemy.attack(), self.enemy.damage)
开发者ID:Martin95056,项目名称:Dungeons,代码行数:47,代码来源:test_enemy.py

示例2: TestEnemy

# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_healing [as 别名]
class TestEnemy(unittest.TestCase):

    def setUp(self):
        self.enemy = Enemy(health=110, mana=110, damage=35)

    def test_create_new_instance(self):
        self.assertTrue(isinstance(self.enemy, Enemy))

    def test_valid_members(self):
        self.assertEqual(self.enemy.health, 110)
        self.assertEqual(self.enemy.mana, 110)
        self.assertEqual(self.enemy.damage, 35)

        self.assertEqual(self.enemy.max_health, 110)
        self.assertEqual(self.enemy.max_mana, 110)

    def test_is_alive(self):
        self.assertTrue(self.enemy.is_alive())
        self.enemy.health = 0
        self.assertFalse(self.enemy.is_alive())

    def test_can_cast_without_spell(self):
        self.assertFalse(self.enemy.can_cast())

    def test_can_cast_with_more_mana(self):
        self.enemy.spell = Spell("Chilling Poison", 20, 20, 2)
        self.assertTrue(self.enemy.can_cast())

    def test_can_cast_with_less_mana(self):
        self.enemy.spell = Spell("Chilling Poison", 20, 20, 2)
        self.enemy.mana = 0
        self.assertFalse(self.enemy.can_cast())

    def test_get_health(self):
        self.assertEqual(self.enemy.get_health(), 110)

    def test_get_mana(self):
        self.assertEqual(self.enemy.get_mana(), 110)

    def test_take_damage_more_than_health(self):
        self.enemy.take_damage(150)
        self.assertEqual(self.enemy.health, 0)

    def test_take_damage_less_than_health(self):
        self.enemy.take_damage(100)
        self.assertEqual(self.enemy.health, 10)

    def test_take_healing_dead_enemy(self):
        self.enemy.health = 0
        self.assertFalse(self.enemy.take_healing(200))

    def test_take_healing_with_more_points_than_max_health(self):
        self.enemy.health = 80
        self.assertTrue(self.enemy.take_healing(200))
        self.assertEqual(self.enemy.health, 110)

    def test_take_healing_with_less_points_than_max_health(self):
        self.enemy.health = 90
        self.assertTrue(self.enemy.take_healing(10))
        self.assertEqual(self.enemy.health, 100)

    def test_take_mana_with_more_points_than_max_mana(self):
        self.enemy.mana = 80
        self.enemy.take_mana(200)
        self.assertEqual(self.enemy.mana, 110)

    def test_take_mana_with_negative_mana(self):
        self.enemy.mana = 50
        self.enemy.take_mana(-60)
        self.assertEqual(self.enemy.mana, 0)

    def test_take_mana_with_less_points_than_max_mana(self):
        self.enemy.mana = 65
        self.enemy.take_mana(20)
        self.assertEqual(self.enemy.mana, 85)

    def test_equip(self):
        knife = Weapon("Knife", 10)
        self.enemy.equip(knife)
        self.assertEqual(self.enemy.weapon, knife)

    def test_learn(self):
        mind_blast = Spell("Mind Blast", 20, 55, 2)
        self.enemy.learn(mind_blast)
        self.assertEqual(self.enemy.spell, mind_blast)

    def test_attack_without_equiped_weapon(self):
        self.assertEqual(self.enemy.attack(by="weapon"), 0)

    def test_attack_with_equiped_weapon(self):
        knife = Weapon("Sword", 50)
        self.enemy.equip(knife)
        self.assertEqual(self.enemy.attack(by="weapon"), 50)

    def test_attack_without_learned_spell(self):
        self.assertEqual(self.enemy.attack(by="spell"), 0)

    def test_attack_with_learned_spell(self):
        fire_blast = Spell("Fire Blast", 40, 30, 1)
        self.enemy.learn(fire_blast)
#.........这里部分代码省略.........
开发者ID:stilyantanev,项目名称:Dungeons-And-Pythons,代码行数:103,代码来源:enemy_test.py

示例3: TestEnemy

# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_healing [as 别名]
class TestEnemy(unittest.TestCase):

    def setUp(self):
        self.enemy_alive = Enemy(100, 0, 20)
        self.enemy_1fourthalive = Enemy(25, 0, 20)
        self.enemy_dead = Enemy(0, 50, 20)
        self.enemy_halfalive = Enemy(50, 0, 20)
        self.enemy_3fourthsalive = Enemy(75, 5, 60)
        self.knife = Weapon("knife", 20)
        self.spell = Spell("Fireball", 30, 50, 2)

    def test_init(self):
        self.assertTrue(isinstance(self.enemy_alive, Enemy))
        self.assertTrue(isinstance(self.enemy_dead, Enemy))
        self.assertTrue(isinstance(self.enemy_halfalive, Enemy))

    def test_get_health(self):
        self.assertEqual(self.enemy_alive.get_health(), 100)
        self.assertEqual(self.enemy_dead.get_health(), 0)

    def test_get_mana(self):
        self.assertEqual(self.enemy_alive.get_mana(), 0)
        self.assertEqual(self.enemy_dead.get_mana(), 50)

    def test_is_alive(self):
        self.assertTrue(self.enemy_alive.is_alive())
        self.assertFalse(self.enemy_dead.is_alive())

    def test_can_cast(self):
        self.assertTrue(self.enemy_dead.can_cast())
        self.assertFalse(self.enemy_alive.can_cast())

    def test_take_healing(self):
        with self.assertRaises(CannotHealWithNonPositivePoints):
            self.enemy_1fourthalive.take_healing(-10)
        self.assertFalse(self.enemy_dead.take_healing(20))
        with self.assertRaises(EnemyHasMaxHealth):
            self.enemy_alive.take_healing(10)
        self.assertTrue(self.enemy_halfalive.take_healing(60))
        self.enemy_1fourthalive.take_healing(75)
        self.assertEqual(self.enemy_1fourthalive.get_health(), 100)
        self.enemy_3fourthsalive.take_healing(10)
        self.assertEqual(self.enemy_3fourthsalive.get_health(), 85)

    def test_take_mana(self):
        self.assertFalse(self.enemy_1fourthalive.take_mana())
        self.assertFalse(self.enemy_3fourthsalive.take_mana())
        self.assertFalse(self.enemy_alive.take_mana())
        self.assertFalse(self.enemy_dead.take_mana())
        self.assertFalse(self.enemy_halfalive.take_mana())

    def test_equip(self):
        self.enemy_alive.equip(self.knife)
        self.assertEqual(self.enemy_alive.weapon, self.knife)

    def test_learn(self):
        self.enemy_halfalive.learn(self.spell)
        self.assertEqual(self.enemy_halfalive.spell, self.spell)

    def test_attack(self):
        self.assertEqual(self.enemy_halfalive.attack(by="weapon"), 0)
        self.assertEqual(self.enemy_1fourthalive.attack(by="spell"), None)
        self.enemy_alive.equip(self.knife)
        self.assertEqual(self.enemy_alive.attack(by="weapon"), 20)
        self.enemy_3fourthsalive.learn(self.spell)
        with self.assertRaises(Exception):
            self.enemy_3fourthsalive.attack(by="spell")
开发者ID:anedelcheva,项目名称:Game-Dungeons-and-Pythons,代码行数:69,代码来源:enemy_test.py

示例4: test_take_healing

# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_healing [as 别名]
    def test_take_healing(self):
        damaged_enemy = Enemy(health=50, mana=100, damage=20)

        self.assertTrue(damaged_enemy.take_healing(30))
开发者ID:vassi95,项目名称:Dungeons-and-pythons,代码行数:6,代码来源:enemy_tests.py

示例5: test_take_healing

# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_healing [as 别名]
 def test_take_healing(self):
     e = Enemy(80, 100, 20)
     e.take_healing(15)
     self.assertEqual(e.get_health(), 95)
开发者ID:Antoniy7,项目名称:Dungeon,代码行数:6,代码来源:enemy_test.py


注:本文中的enemy.Enemy.take_healing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。