本文整理汇总了Python中enemy.Enemy.take_mana方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.take_mana方法的具体用法?Python Enemy.take_mana怎么用?Python Enemy.take_mana使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.take_mana方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEnemy
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_mana [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)
#.........这里部分代码省略.........
示例2: test_take_mana
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_mana [as 别名]
def test_take_mana(self):
down_mana_enemy = Enemy(health=100, mana=40, damage=20)
down_mana_enemy.take_mana(30)
self.assertEqual(down_mana_enemy.mana, 40)
示例3: TestEnemy
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_mana [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")
示例4: test_take_mana
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import take_mana [as 别名]
def test_take_mana(self):
e = Enemy(100, 80, 20)
e.take_mana(15)
self.assertEqual(e.get_mana(), 95)