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


Python Orc.attack方法代码示例

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


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

示例1: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.orc = Orc("Berserk", 100, 2)

    def test_orc_init(self):
        self.assertEqual("Berserk", self.orc.name)
        self.assertEqual(100, self.orc.health)
        self.assertEqual(2, self.orc.berserk_factor)

    def test_berserk_factor_over(self):
        tincho = Orc("Tincho", 200, 5)
        self.assertTrue(tincho.berserk_factor in [1, 2])

    def test_berserk_factor_under(self):
        pencho = Orc("Pencho", 210, 0.5)
        self.assertTrue(pencho.berserk_factor in [1, 2])

    def test_attack_berserk_with_weapon(self):
        weapon = Weapon("Mighty Axe", 25, 0.2)
        self.orc.equip_weapon(weapon)
        self.assertEqual(25 * 2, self.orc.attack())

    def test_attack_berserk_without_weapon(self):
        self.assertEqual(0, self.orc.attack())
开发者ID:antonpetkoff,项目名称:Programming101,代码行数:27,代码来源:orc_test.py

示例2: OrcTests

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class OrcTests(unittest.TestCase):

    def setUp(self):
        self.the_orc = Orc("Oplik", 122, 1.42)

    def test_orc_init(self):
        self.assertEqual(1.42, self.the_orc.berserk_factor)

    def test_set_berserk_factor(self):
        self.the_orc.set_berserk_factor(2.55)
        self.assertEqual(2, self.the_orc.berserk_factor)
        self.the_orc.set_berserk_factor(0.55)
        self.assertEqual(1, self.the_orc.berserk_factor)

    def test_orc_attack_no_weapon(self):
        self.assertEqual(0, self.the_orc.attack())

    # that's a stupid test, fix it later!
    def test_orc_attack(self):
        weapon = Weapon("spoon", 2, 0.7)
        self.the_orc.equip_weapon(weapon)
        critical = False
        normal = False
        critical_num = 4 * self.the_orc.berserk_factor
        normal_num = 2 * self.the_orc.berserk_factor
        for i in range(0, 1000):
            critical = critical or (critical_num == self.the_orc.attack())
            normal = normal or (normal_num == self.the_orc.attack())
        self.assertTrue(critical)
        self.assertTrue(normal)
开发者ID:Fusl,项目名称:Hack-Bulgaria-Programming-101,代码行数:32,代码来源:orc_test.py

示例3: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.grom_orc = Orc("Grom", 100, 1.5)

    def test_orc_init(self):
        self.assertEqual("Grom", self.grom_orc.name)
        self.assertEqual(100, self.grom_orc.health)
        self.assertEqual(1.5, self.grom_orc.berserk_factor)

    def test_orc_berserk_factor_init(self):
        self.orc = Orc("Orc", 100, 0.2)
        self.assertEqual(self.orc.berserk_factor, 1)
        self.orc2 = Orc("test", 100, 2.6)
        self.assertEqual(self.orc2.berserk_factor, 2)

    def test_orc_attack(self):
        weapon = Weapon("Axe", 30, 0.2)
        self.grom_orc.equip(weapon)
        crit = False
        not_crit = False
        for i in range(100):
            if self.grom_orc.attack() == 90:
                crit = True
            elif self.grom_orc.attack() == 45:
                not_crit = True
        self.assertTrue(crit and not_crit)
开发者ID:nkgeorgiev,项目名称:HackBulgaria---Programming101---2,代码行数:28,代码来源:orc_test.py

示例4: OrcTest

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class OrcTest (unittest.TestCase):
    def setUp(self):
        self.orc = Orc("Gosho", 100, 1.25)

    def test_orc_init(self):

        self.assertEqual(self.orc.name, "Gosho")
        self.assertEqual(self.orc.health, 100)
        self.assertEqual(self.orc.berserk_factor, 1.25)

    def test_get_health(self):

        self.assertEqual(self.orc.get_health(), 100)

    def test_is_alive_return_false(self):

        self.orc.fight_health = 0
        self.assertFalse(self.orc.is_alive())

    def test_is_alive(self):

        self.assertTrue(self.orc.is_alive())

    def test_take_damage(self):

        self.assertEqual(80, self.orc.take_damage(20))

    def test_take_damage_more_than_health(self):

        self.assertEqual(0, self.orc.take_damage(120))

    def test_take_healing_to_dead_person(self):

        self.orc.health = 0
        self.assertFalse(self.orc.take_healing(20))

    def test_take_healing_more_than_full_health(self):

        self.orc.health = 90
        self.assertFalse(self.orc.take_healing(100))

    def test_take_healing_true(self):

        self.orc.health = 40

    def test_berserk_factor_below_one(self):
        self.orc.berserk_factor = 0.4
        self.assertEqual(self.orc.berserk_factor_check(), 1)

    def test_berserk_factor_over_two(self):
        self.orc.berserk_factor = 2.14
        self.assertEqual(self.orc.berserk_factor_check(), 2)

    def test_orc_attack_with_weapon(self):
        self.orc.equip_weapon(Weapon("Pipe", 35, 0.5))
        self.assertEqual(self.orc.attack(), 70)

    def test_orc_attack_without_weapon(self):
        self.assertEqual(self.orc.attack(), 0)
开发者ID:JusttRelaxx,项目名称:HackBulgaria,代码行数:61,代码来源:the_orc_test.py

示例5: WeaphonTest

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class WeaphonTest(unittest.TestCase):

    def setUp(self):
        self.sniper = Weaphon("Gun", 85, 0.10)
        self.hammer = Weaphon("One-Hand", 30, 0)
        self.bron_orc = Orc("Pesho", 100, 1.50)
        self.bron_hero = Hero("Ivan", 100, "Magician")

    def test_weaphon_initialization(self):
        self.assertEquals("Gun", self.sniper.type)
        self.assertEquals(85, self.sniper.damage)
        self.assertEquals(0.10, self.sniper.critical_strike_percent)

    def test_crit_hit_sniper(self):
        temp = False
        for i in range(100):
            if temp:
                break
            else:
                temp = self.sniper.critical_hit()
        self.assertTrue(temp)

    def test_crit_hit_hammer(self):
        temp = False
        for i in range(100):
            if temp:
                break
            else:
                temp = self.hammer.critical_hit()
        self.assertFalse(temp)

    def test_entity_has_weaphon(self):
        self.bron_orc.equip_weapon(self.hammer)
        self.assertTrue(self.bron_orc.has_weaphon())

    def test_entity_do_not_has_wep(self):
        self.assertFalse(self.bron_orc.has_weaphon())

    def test_entity_equip_weaphon_first_time(self):
        self.bron_orc.equip_weapon(self.hammer)
        self.assertEqual("One-Hand", self.bron_orc.weaphon.type)

    def test_equip_weaphon_when_the_entity_allready_has_one(self):
        self.bron_orc.equip_weapon(self.hammer)
        self.bron_orc.equip_weapon(self.sniper)
        self.assertEqual("Gun", self.bron_orc.weaphon.type)

    def test_attack_no_weaphon(self):
        self.assertEqual(0, self.bron_orc.attack())

    def test_atack_hero(self):
        self.bron_hero.equip_weapon(self.hammer)
        self.assertEqual(30, self.bron_hero.attack())

    def test_atack_orc(self):
        self.bron_orc.equip_weapon(self.hammer)
        self.assertEqual(45, self.bron_orc.attack())
开发者ID:golfdman,项目名称:HackBulgaria,代码行数:59,代码来源:test_hero.py

示例6: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.orc = Orc('Broks', 100, 1.5)

    def test_orc_init_berserk(self):
        self.assertEqual(self.orc.berserk_factor, 1.5)

    def test_orc_attack_without_weapon(self):
        self.assertEqual(self.orc.attack(), 0)

    def test_orc_attack_with_weapon(self):
        axe = Weapon('Axe', 25, 0.5)
        self.orc.equip_weapon(axe)
        self.assertEqual(self.orc.attack(), 25*1.5)
开发者ID:stoyaneft,项目名称:HackBulgariaProgramming-101,代码行数:17,代码来源:test_orc.py

示例7: test_Orc_attack_with_weapon

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
 def test_Orc_attack_with_weapon(self):
     my_weapon = Weapon("Axe", 31, 0.2)
     my_Orc = Orc("Ivan", 100, 1.5)
     my_Orc.equip_weapon(my_weapon)
     attack = my_weapon.damage * (1 + my_weapon.critical_strike_percent) * my_Orc.berserk_factor
     true_attack = my_Orc.attack()
     self.assertEqual(attack, true_attack)
开发者ID:Hristiyan-Andreev,项目名称:HackBuglaria,代码行数:9,代码来源:orcTest.py

示例8: OrcTest

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class OrcTest(unittest.TestCase):

    def setUp(self):
        self.zaithan_orc = Orc('Zaithan', 200, 1.7)
        self.destroyer_weapon = Weapon('Destroyer Axe', 30, 0.7)

    def test_set_berserk_factor(self):
        self.shatterer_orc = Orc('Shatterer', 250, 30.3)
        self.assertEqual(self.shatterer_orc.berserk_factor, 2)

    def test_return_attack_with_weapon(self):
        self.zaithan_orc.equip_weapon(self.destroyer_weapon)
        self.assertIn(self.zaithan_orc.attack(), [51, 102])

    def test_return_attack_without_weapon(self):
        self.assertEqual(0, self.zaithan_orc.attack())
开发者ID:Shosh,项目名称:hackBulgaria_programming101,代码行数:18,代码来源:orc_test.py

示例9: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.born_orc = Orc("Shapeshifter", 100, 1.5)

    def test_orc_init(self):
        self.assertEqual(self.born_orc.name, "Shapeshifter")
        self.assertEqual(self.born_orc.health, 100)
        self.assertEqual(self.born_orc.berserk, 1.5)

    def test_berserk_check_more(self):
        self.born_orc = Orc("Shapeshifter", 100, 3)
        self.assertEqual(self.born_orc.berserk, 2)

    def test_berserk_check_less(self):
        self.born_orc = Orc("Shapeshifter", 100, 0.2)
        self.assertEqual(self.born_orc.berserk, 1)

    def test_berserk_check(self):
        self.assertEqual(self.born_orc.berserk, 1.5)

    def test_attack(self):
        self.born_orc.weapon = Weapon("Mighty Axe", 20, 0.5)
        damages = set()
        for i in range(1000):
            damages.add(self.born_orc.attack())

        self.assertIn(30.0, damages)
        self.assertIn(60.0, damages)
开发者ID:stoilov,项目名称:Programming101,代码行数:31,代码来源:orc_test.py

示例10: OrcTest

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class OrcTest(unittest.TestCase):

    def setUp(self):
        self.orc = Orc("Thrall", 200, 1.7)
        self.orc.weapon = Weapon("Frostmourne", 35, 0.7)

    def test_init(self):
        self.assertEqual(self.orc.name, "Thrall")
        self.assertEqual(self.orc.health, 200)
        self.assertEqual(self.orc.berserk_factor, 1.7)

    def test_berserk_set_with_higher_value(self):
        result = self.orc.set_berserk_factor(3.5)
        self.assertEqual(result, 2.0)

    def test_berserk_set_with_lower_value(self):
        result = self.orc.set_berserk_factor(0.4)
        self.assertEqual(result, 1.0)

    def test_berserk_set_with_negative(self):
        result = self.orc.set_berserk_factor(-5)
        self.assertEqual(result, 1.0)

    def test_has_weapon_when_present(self):
        self.assertEqual(self.orc.has_weapon(), True)

    def test_has_weapon_when_not_present(self):
        self.orc.weapon = None
        self.assertEqual(self.orc.has_weapon(), False)

    def test_equip_stronger_weapon(self):
        test_weapon = Weapon("Stick", 500, 0.1)
        self.orc.equip_weapon(test_weapon)
        self.assertEqual(self.orc.weapon, test_weapon)

    def test_equip_weaker_weapon(self):
        test_weapon = Weapon("Stick", 5, 0.1)
        self.orc.equip_weapon(test_weapon)
        self.assertNotEqual(self.orc.weapon, test_weapon)

    def test_attack_when_no_weapon_is_equipped(self):
        self.orc.weapon = None
        self.assertEqual(self.orc.attack(), 0)

    def test_attack_when_weapon_is_equipped(self):
        self.assertIn(self.orc.attack(), [35 * 1.7, 70 * 1.7])
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:48,代码来源:test_all.py

示例11: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.orc = Orc("Thrall", 100, 1.5)
        self.bradva = Weapon("Axe", 16, 0.4)
        self.orc.weapon = self.bradva
        self.unarmedOrc = Orc("Unarmed", 100, 1.3)

    def test_init(self):
        self.assertEqual(self.orc.name, "Thrall")
        self.assertEqual(self.orc.health, 100)
        self.assertEqual(self.orc.berserk_factor, 1.5)

    def test_damage_if_entity_is_orc(self):
        self.assertIn(self.orc.attack(), [24, 48])

    def test_attack_if_orc_is_unequipped(self):
        result = self.unarmedOrc.attack()
        self.assertEqual(0, result)
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:20,代码来源:orc_test.py

示例12: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.new_orc = Orc("Yurnero", 100, 100, 1.23)
        self.new_weapon = Weapon("Some Sword", 1, 0)
        self.without_weapon = Weapon("With bare hands", 0, 0)

    def test_init(self):
        self.assertEqual(1.23, self.new_orc.berserk_factor)

    def test_berserk_factor(self):
        self.new_orc._set_berserk_factor(2.5)
        self.assertEqual(2, self.new_orc.berserk_factor)
        self.new_orc._set_berserk_factor(0.5)
        self.assertEqual(1, self.new_orc.berserk_factor)

    def test_berserk_atack(self):
        self.new_orc.equip_weapon(self.new_weapon)
        self.assertEqual(1.23, self.new_orc.attack())
        self.new_orc.equip_weapon(self.without_weapon)
        self.assertEqual(0, self.new_orc.attack())
开发者ID:VictorVangelov,项目名称:HackBulgaria,代码行数:23,代码来源:test_orc.py

示例13: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.bron_orc = Orc("Bron", 100, 1.3)

    def test_orc_init(self):
        self.assertEqual(self.bron_orc.berserk_factor, 1.3)

    def test_init_incorect_berserk_factor(self):
        with self.assertRaises(ValueError):
            Orc("Bron", 100, 2.3)

    def test_attack(self):
        self.assertEqual(self.bron_orc.attack(), self.bron_orc.damage)
开发者ID:AlexanderTankov,项目名称:HackBulgaria-Programming-101,代码行数:15,代码来源:orc_test.py

示例14: TestHero

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestHero(unittest.TestCase):

    def setUp(self):
        self.hell_orc = Orc("Hell", 100, 1.4)
        self.axe = Weapon("Axe", 10, 0.2)

    def test_attributes(self):
        self.assertEqual(1.4, self.hell_orc.berserk_factor)

    def test_berserk_over(self):
        self.assertEqual(2, self.hell_orc._normalize_berserk_factor(3))

    def test_berserk_under(self):
        self.assertEqual(1, self.hell_orc._normalize_berserk_factor(0.5))

    def test_attack(self):
        self.hell_orc.equip_weapon(self.axe)
        self.assertEqual(1.4 * self.hell_orc.equipped_weapon.damage,
                         self.hell_orc.attack())
开发者ID:maieutiquer,项目名称:dungeons-and-pythons,代码行数:21,代码来源:test_orc.py

示例15: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import attack [as 别名]
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.thrall = Orc("Thrall", 100, 1.2)

    def test_orc_init(self):
        self.assertEqual(100, self.thrall.health)
        self.assertEqual("Thrall", self.thrall.name)
        self.assertEqual(1.2, self.thrall.berserk_factor)

    def test_berserk_factor_within_bounds(self):
        normal_berserking_orc = Orc("Aaaaaa", 100, 1.89)
        self.assertEqual(1.89, normal_berserking_orc.berserk_factor)

    def test_berserk_factor_out_of_bounds(self):
        berserking_orc = Orc("Gromash", 100, 3)
        self.assertEqual(2, berserking_orc.berserk_factor)

        less_berserking_orc = Orc("Not Gromash", 100, -20)
        self.assertEqual(1, less_berserking_orc.berserk_factor)

    def test_attack_with_berserk_factor(self):
        self.thrall.equip_weapon(Weapon("Pickaxe", 38, 0.6))
        self.assertEqual(self.thrall.weapon.damage * self.thrall.berserk_factor,
                         self.thrall.attack())
开发者ID:betrakiss,项目名称:HackBulgaria,代码行数:26,代码来源:orc_test.py


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