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


Python Entity.equip_weapon方法代码示例

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


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

示例1: test_has_weapon

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import equip_weapon [as 别名]
 def test_has_weapon(self):
     my_weapon = Weapon("axe", 30, 0.5)
     my_entity = Entity("Furious", 100)
     my_entity.equip_weapon(my_weapon)
     self.assertTrue(my_entity.has_weapon())
     my_entity = Entity("Furious", 100)
     self.assertFalse(my_entity.has_weapon())
开发者ID:AntonioFilipov,项目名称:HackBulgaria-Programming101,代码行数:9,代码来源:Entity_test.py

示例2: Test_Entity

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import equip_weapon [as 别名]
class Test_Entity(unittest.TestCase):

    def setUp(self):
        self.entity = Entity("Kung-Fu Balhar", 100)
        self.otherentity = Entity("Balha", 100)
        self.entity.weapon = Weapon("Kaish", 50, 0.5)

    def test_entity_name(self):
        output = "Kung-Fu Balhar"
        result = self.entity.name
        self.assertEqual(result, output)

    def test_get_entity_health(self):
        output = 100
        result = self.entity.get_health()
        self.assertEqual(result, output)

    def test_is_entity_alive(self):
        self.assertTrue(self.entity.is_alive())

    def test_entity_take_damage(self):
        health_left = 60
        damage = 40
        result = self.entity.get_health() - damage
        self.assertEqual(health_left, result)

    def test_entity_take_healing_when_not_dead_and_has_max_hp(self):
        self.assertFalse(self.entity.take_healing(10))

    def test_entity_take_healing_when_not_dead_and_has_less_than_max_hp(self):
        self.entity.health -= 10
        self.assertTrue(self.entity.take_healing(10))

    def test_entity_take_healing_when__dead(self):
        self.entity.health -= 100
        self.assertFalse(self.entity.take_healing(10))

    def test_has_weapon_when_weapon_not_equipped(self):
        result = self.otherentity.has_weapon()
        self.assertFalse(result)

    def test_has_weapon_when_weapon_equipped(self):
        self.weapon = Weapon("Mighty Axe", 25, 0.2)
        self.entity.equip_weapon(self.weapon)
        result = self.entity.has_weapon()
        self.assertTrue(result)

    def test_equip_weapon(self):
        self.weapon = Weapon("Mighty Axe", 25, 0.2)
        result = self.entity.equip_weapon(self.weapon)
        self.assertTrue(result)

    def test_damage_of_entity_when_weapon_equipped(self):
        self.assertEqual(self.entity.attack(), 50)

    def test_damage_of_entity_when_weapon_not_equipped(self):
        self.assertEqual(self.otherentity.attack(), 0)
开发者ID:VasilVasilev93,项目名称:HackBulgaria,代码行数:59,代码来源:Entity_test.py

示例3: TestEntityClass

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import equip_weapon [as 别名]
class TestEntityClass(unittest.TestCase):
    def setUp(self):
        self.entity = Entity('Baba', 100)

    def test_initialisation_atributes(self):
        self.assertEqual(self.entity.name, 'Baba')
        self.assertEqual(self.entity.health, 100)

    def test_get_health(self):
        self.assertEqual(self.entity.get_health(), 100)

    def test_is_alive(self):
        self.assertTrue(self.entity.is_alive())
        self.entity = Entity('Baba', 0)
        self.assertFalse(self.entity.is_alive())

    def test_take_damage(self):
        self.assertTrue(self.entity.take_damage(50))
        self.assertEqual(self.entity.get_health(), 50)

        self.assertTrue(self.entity.take_damage(51))
        self.assertEqual(self.entity.get_health(), 0)
        self.assertFalse(self.entity.take_damage(10))

    def test_take_healing(self):
        self.assertTrue(self.entity.take_healing(100))
        self.assertEqual(self.entity.get_health(), 100)
        self.entity.take_damage(50)
        self.assertTrue(self.entity.take_healing(40))
        self.assertEqual(self.entity.get_health(), 90)

        self.entity = Entity('Baba', 0)
        self.assertFalse(self.entity.take_healing(100))

    def test_has_weapon(self):
        self.assertFalse(self.entity.has_weapon())

    def test_equip_weapon(self):
        sword = Weapon('Sword', 100, 0.4)
        sword2 = Weapon('Sword', 100, 0.4)
        self.entity.equip_weapon(sword)
        self.assertTrue(self.entity.has_weapon())
        self.assertEqual(self.entity.weapon, sword)
        self.entity.equip_weapon(sword2)
        self.assertNotEqual(self.entity.weapon, sword)

    def test_attack(self):
        self.assertEqual(self.entity.attack(), 0)
        sword = Weapon('Sword', 100, 0)
        self.entity.equip_weapon(sword)
        self.assertEqual(self.entity.attack(), 100)

        sword = Weapon('Sword', 100, 1)
        self.entity.equip_weapon(sword)
        self.assertEqual(self.entity.attack(), 200)
开发者ID:alexnad,项目名称:HackBulgaria-Programming-101-2,代码行数:57,代码来源:EntityTest.py

示例4: test_attack_with_weapon

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import equip_weapon [as 别名]
 def test_attack_with_weapon(self):
     my_entity = Entity("Furious", 100)
     my_weapon = Weapon("axe", 30, 0.5)
     my_entity.equip_weapon(my_weapon)
     self.assertEqual(30, my_entity.attack())
开发者ID:AntonioFilipov,项目名称:HackBulgaria-Programming101,代码行数:7,代码来源:Entity_test.py


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