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


Python Orc.equip_weapon方法代码示例

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


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

示例1: test_Orc_attack_with_weapon

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [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

示例2: TestFight

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

    def setUp(self):
        self.my_hero = Hero("Hero",  100, "Hero")
        self.my_orc = Orc("Orc", 100, 1.5)
        self.the_fight = Fight(self.my_hero, self.my_orc)

    def test_init(self):
        self.assertEqual(self.my_hero.name, "Hero")
        self.assertEqual(self.my_hero.health, 100)
        self.assertEqual(self.my_hero.nickname, "Hero")
        self.assertEqual(self.my_orc.name, "Orc")
        self.assertEqual(self.my_orc.health, 100)
        self.assertEqual(self.my_orc.berserk_factor, 1.5)

    def test_attacks_first(self):
        my_arr = []
        for i in range(0, 100):
            if self.the_fight.attacks_first() == True:
                my_arr.append(1)
            my_arr.append(0)
        self.assertIn(1, my_arr)
        self.assertIn(0, my_arr)

    def test_simulate_fight(self):
        proba1 = Weapon("axe", 1, 0.1)
        proba2 = Weapon("sword", 40, 0.9)
        self.my_hero.equip_weapon(proba1)
        self.my_orc.equip_weapon(proba2)
        the_fight = Fight(self.my_hero, self.my_orc)
        self.assertFalse(the_fight.simulate_fight())
开发者ID:skdls-,项目名称:Python,代码行数:33,代码来源:test_fight.py

示例3: FightTest

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

    def setUp(self):
        self.bron_hero = Hero("Bron", 100, "DragonSlayer")
        self.torug_orc = Orc("Torug", 100, 1.2)
        self.new_fight = Fight(self.bron_hero, self.torug_orc)
        self.axe = Weapon("Axe", 20, 0.2)
        self.sword = Weapon("Sword", 12, 0.7)
        self.bron_hero.equip_weapon(self.sword)
        self.torug_orc.equip_weapon(self.axe)

    def test_init(self):
        self.assertEqual(self.new_fight.orc, self.torug_orc)
        self.assertEqual(self.new_fight.hero, self.bron_hero)

    def test_who_is_first(self):
        first_entity = self.new_fight.who_is_first()
        self.assertIn(first_entity, [self.bron_hero, self.torug_orc])

    def test_fight(self):
        self.new_fight.simulate_battle()
        self.assertFalse(self.torug_orc.is_alive() and self.bron_hero.is_alive())

    def test_fight_with_no_weapons(self):
        self.torug_orc.weapon = None
        self.new_fight.simulate_battle()
        self.assertFalse(self.torug_orc.is_alive())
开发者ID:ivaylospasov,项目名称:programming-101,代码行数:29,代码来源:fight_test.py

示例4: OrcTests

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [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

示例5: TestOrc

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [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

示例6: setUp

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def setUp(self):
     weapon = Weapon('Dagger', 10, 0.0)
     hero = Hero('Asd', 100, 'Hero')
     hero.equip_weapon(weapon)
     orc = Orc('Dsa', 1, 1.4)
     orc.equip_weapon(weapon)
     self.fight = fight.Fight(hero, orc)
开发者ID:smo93,项目名称:hackbulgaria,代码行数:9,代码来源:fight_test.py

示例7: test_simulate_fight_orc_win

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def test_simulate_fight_orc_win(self):
     orc_w = Orc("Winner", 300, 2)
     hero_l = Hero("Loser", 300, "TheLoser")
     wep = Weapon("Ubiec", 15, 0.5)
     orc_w.equip_weapon(wep)
     orc_fight = Fight(hero_l, orc_w)
     self.assertEqual(orc_fight.simulate_fight(), orc_fight._ORC_WINNER)
开发者ID:SlaviSotirov,项目名称:HackBulgaria,代码行数:9,代码来源:fight_test.py

示例8: OrcTest

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [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

示例9: test_fight1

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def test_fight1(self):
     new_hero = Hero("Jack", 100, "Ripper")
     new_orc = Orc("Gruumsh", 40, 1.2)
     hero_weapon = Weapon("The Sting", 8, 0.33)
     orc_weapon = Weapon("The Pacifier", 12, 1)
     new_hero.equip_weapon(hero_weapon)
     new_orc.equip_weapon(orc_weapon)
     Fight(new_hero, new_orc)
开发者ID:didoman,项目名称:prog101tasks,代码行数:10,代码来源:dnp_tests.py

示例10: TestDungeon

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

    def setUp(self):

        self.without_weapon = Weapon("With bare hands", 0, 0)
        self.thanes_hummer = Weapon("Thanes hummer", 15, 0.4)
        self.yurnero_blade = Weapon("Yurneros blade", 10, 0.35)
        self.the_hero = Hero("Thanes", 150, 150, "Mountain King")
        self.the_orc = Orc("Yurnero the Blademaster", 150, 150, 1.3)
        self.the_chen = Orc("Chen", 150, 150, 1.3)
        self.small_potion = Potion("Small potion", 15)
        self.midium_potion = Potion("Midium potion", 25)
        self.the_hero.equip_weapon(self.thanes_hummer)
        self.the_orc.equip_weapon(self.yurnero_blade)
        self.map = Dungeon("map.txt")
        self.map.read_map()
        self.map.dict_of_items[self.yurnero_blade] = []
        self.map.dict_of_items[self.thanes_hummer] = []
        self.map.dict_of_items[self.small_potion] = []
        self.map.dict_of_items[self.midium_potion] = []
        self.map.dict_of_herous[self.the_orc] = []
        self.map.dict_of_herous[self.the_hero] = []
        self.map.spawn_player("shosho", self.the_hero)
        #self.map.spawn_player("kosho", self.the_orc)
        #self.map.dict_champion_name[self.the_hero] = "shosho"
        self.map.dict_champion_name[self.the_orc] = "kosho"



    #def test_validate_player(self):
    #    self.assertEqual(self.the_hero, self.map.validate_player_name("hero"))
    def test_spawn_player(self):
        #self.assertFalse(self.map.spawn_player("shosho", self.the_hero))
        self.assertTrue(self.map.spawn_player("kosho", self.the_orc))
        self.assertFalse(self.map.spawn_player("kosho", self.the_chen))

    def test_can_move(self):
        #print("{}\n{}".format(self.map.number_of_rows, self.map.number_of_chars))
        #print((self.map.number_of_rows))
        self.current_user = self.the_orc
        self.map.print_map()

        self.assertFalse(self.map.can_move_up(-1, 0))
        self.assertFalse(self.map.can_move_down(1, 0))
        self.assertTrue(self.map.can_move_right(0, 1))
        self.map.validate_player_name("orc")
        print("{}     {}".format(self.map.current_x, self.map.current_y))
        self.assertFalse(self.map.can_move_up(-1, 0))
        self.assertFalse(self.map.can_move_down(1, 0))
        self.assertTrue(self.map.can_move_right(0, 1))
        self.assertFalse(self.map.can_move_left(0, -1))

    def test_validate_player_name(self):

        self.map.spawn_player("kosho", self.the_orc)
        self.assertEqual(self.map.validate_player_name("kosho"), self.the_orc)
        self.map.print_map()
开发者ID:VictorVangelov,项目名称:HackBulgaria,代码行数:59,代码来源:test_dungeon.py

示例11: test_orc_wins

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def test_orc_wins(self):
     hero = Hero("Bron", 50, "DragonSlayer")
     evil_orc = Orc('karakondjul', 100 , 1.5)
     weapon1 = Weapon("Axe", 1, 0.5)
     weapon2 = Weapon("Sword", 34, 0.5)
     hero.equip_weapon(weapon1)
     evil_orc.equip_weapon(weapon2)
     fight = Fighting(hero,evil_orc)
     winner = fight.simulate_fight()
     self.assertTrue(isinstance(winner,Orc))
开发者ID:dsspasov,项目名称:HackBulgaria,代码行数:12,代码来源:fighting_test.py

示例12: test_fight

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def test_fight(self):
     my_Hero = Hero("Ivan", 100, "bad ass")
     my_Orc = Orc("Boko", 100, 1.5)
     my_weapon1 = Weapon("Axe1", 31, 0.2)
     my_weapon2 = Weapon("Axe2", 31, 0.2)
     my_Hero.equip_weapon(my_weapon1)
     my_Orc.equip_weapon(my_weapon2)
     fight1 = Fight(my_Hero, my_Orc)
     fight1.simulate_fight()
     self.assertFalse(my_Orc.is_alive() and my_Hero.is_alive())
开发者ID:Hristiyan-Andreev,项目名称:HackBuglaria,代码行数:12,代码来源:fightingTest.py

示例13: test_move_and_fight

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
 def test_move_and_fight(self):
     boromir = Hero("Boromir", 100, "OneDoesNotSimply")
     gollum = Orc("Gollum", 100, 1.5)
     axe = Weapon("Mighty Axe", 25, 0.2)
     sword = Weapon("Sword", 25, 0.2)
     boromir.equip_weapon(sword)
     gollum.equip_weapon(axe)
     self.dungeon.spawn("player_1", boromir)
     self.dungeon.spawn("player_2", gollum)
     self.dungeon.spawned["player_2"][1] = 12
     self.dungeon.move("player_1", "right")
     been_fight = self.dungeon.spawned["player_1"][0].is_alive() and self.dungeon.spawned["player_2"][0].is_alive()
     self.assertFalse(been_fight)
开发者ID:stoilov,项目名称:Programming101,代码行数:15,代码来源:dungeon_test.py

示例14: TestFight

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

    def setUp(self):
        self.orc = Orc("Berserk", 1000, 2)
        self.hero = Hero("Bron", 1000, "DragonSlayer")
        self.weapon = Weapon("Mighty Axe", 25, 0.3)
        self.orc.equip_weapon(self.weapon)
        self.hero.equip_weapon(self.weapon)
        self.fight = Fight(self.hero, self.orc)

    def test_simulate_fight(self):
        self.fight.simulate_fight()
        self.assertTrue(not self.orc.is_alive() or not self.hero.is_alive())
开发者ID:antonpetkoff,项目名称:Programming101,代码行数:15,代码来源:fight_test.py

示例15: TestFight

# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import equip_weapon [as 别名]
class TestFight(unittest.TestCase):
    def setUp(self):
        self.varyan = Hero("Varyan Wrynn", 100, "King")
        self.garrosh = Orc("Garrosh Hellscream", 100, 7)

        self.weak_weapon = Weapon("Noob Weapon", 10, 0.1)
        self.strong_weapon = Weapon("Woo Weapon", 20, 0.7)

        self.fight = Fight(self.varyan, self.garrosh)

    def test_simulate_fight_win(self):
        self.varyan.equip_weapon(self.strong_weapon)
        self.garrosh.equip_weapon(self.weak_weapon)
        self.assertIsNotNone(self.fight.simulate_fight())
开发者ID:betrakiss,项目名称:HackBulgaria,代码行数:16,代码来源:fight_test.py


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