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


Python Hero.equip_weapon方法代码示例

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


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

示例1: FightTest

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

示例2: test_simulate_fight_hero_win

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

示例3: TestFight

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

示例4: setUp

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

示例5: test_fight1

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

示例6: test_fight_with_one_weapon

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

示例7: WeaphonTest

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

示例8: TestDungeon

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

示例9: test_fight

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

示例10: test_orc_wins

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

示例11: TestFight

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

示例12: test_move_and_fight

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

示例13: TestFight

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

示例14: execute_necessary_inits

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import equip_weapon [as 别名]
 def execute_necessary_inits(self):
     thanes_hummer = Weapon("Thanes hummer", 15, 0.4)
     yurnero_blade = Weapon("Yurneros blade", 10, 0.35)
     the_hero = Hero("Thanes", 150, 150, "Mountain King")
     the_orc = Orc("Yurnero the Blademaster", 150, 150, 1.3)
     small_potion = Potion("Small potion", 15)
     midium_potion = Potion("Midium potion", 25)
     the_hero.equip_weapon(thanes_hummer)
     the_orc.equip_weapon(yurnero_blade)
     self.dungeon.dict_of_items[yurnero_blade] = []
     self.dungeon.dict_of_items[thanes_hummer] = []
     self.dungeon.dict_of_items[small_potion] = []
     self.dungeon.dict_of_items[midium_potion] = []
     self.dungeon.dict_of_herous[the_orc] = []
     self.dungeon.dict_of_herous[the_hero] = []
开发者ID:VictorVangelov,项目名称:HackBulgaria,代码行数:17,代码来源:simulate_game.py

示例15: TestFight

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

    def setUp(self):
        self.hero = Hero("Aiden", 500, "Daro Wonderer")
        self.orc = Orc("Thrall", 400, 1.4)
        weapon1 = Weapon("The Ash Bringer", 80, 0.5)
        weapon2 = Weapon('DoomHammer', 80, 0.5)
        self.hero.equip_weapon(weapon1)
        self.orc.equip_weapon(weapon2)

        self.fight = Fight(self.hero, self.orc)

    def test_simulate_fight(self):
        self.fight.simulate_fight()
        self.assertTrue(self.hero.is_alive() or self.orc.is_alive())
        self.assertFalse(self.orc.is_alive() and self.hero.is_alive())
开发者ID:NikiMaslarski,项目名称:HackBulgari_Programming101,代码行数:18,代码来源:fight_test.py


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