本文整理汇总了Python中orc.Orc类的典型用法代码示例。如果您正苦于以下问题:Python Orc类的具体用法?Python Orc怎么用?Python Orc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Orc类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
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)
示例2: test_Orc_attack_with_weapon
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)
示例3: FightTest
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())
示例4: FightTest
class FightTest(unittest.TestCase):
def setUp(self):
self.hero_one = Hero("Bron", 100, "DragonSlayer")
self.orc_one = Orc("Orcy", 150, 1.5)
self.fight_one = fight.Fight(self.hero_one, self.orc_one)
self.axe = Weapon("Axe", 20, 0.2)
self.sword = Weapon("Sword", 12, 0.7)
self.hero_one.weapon = self.sword
self.orc_one.weapon = self.axe
def test_init(self):
self.assertEqual(self.fight_one.hero, self.hero_one)
self.assertEqual(self.fight_one.orc, self.orc_one)
def test_fight(self):
self.fight_one.simulate_battle()
# if one of them died
self.assertFalse(self.orc_one.is_alive() and self.hero_one.is_alive())
def test_fight_no_weapon(self):
self.orc_one.weapon = None
self.fight_one.simulate_battle()
# orc has no weapon => orc dies
self.assertFalse(self.orc_one.is_alive())
def test_fight_equal(self):
hero_one = Hero("Bron", 100, "DragonSlayer")
orc_one = Orc("Orcy", 150, 1.5)
hero_one.weapon = Weapon("Axe", 20, 0.5)
orc_one.weapon = Weapon("Axe", 20, 0.5)
self.fight_one.simulate_battle()
# both has the same weapon, but the orc has berserc_factor,\
# he should be alive at the end
self.assertTrue(self.orc_one.is_alive())
示例5: TestOrc
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)
示例6: TestFight
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())
示例7: TestOrc
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())
示例8: test_simulate_fight_orc_win
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)
示例9: test_battle
def test_battle(self):
orc = Orc("Bron", 100, 1.3)
hero = Hero("Bron", 100, "DragonSlayer")
axe = Weapon("Mighty Axe", 25, 0.2)
orc.weapon = axe
self.my_map.spawn("player_1", orc)
self.my_map.spawn("player_2", hero)
self.my_map.move("player_1", "right")
self.my_map.move("player_1", "left")
self.my_map.move("player_1", "right")
self.my_map.move("player_2", "up")
self.my_map.move("player_1", "down")
self.my_map.move("player_1", "down")
self.my_map.move("player_1", "down")
for i in range(0, 4):
self.my_map.move("player_2", "up")
for i in range(0, 4):
self.my_map.move("player_2", "left")
self.my_map.move("player_2", "down")
self.my_map.move("player_2", "down")
self.my_map.move("player_2", "down")
self.my_map.move("player_1", "right")
self.my_map.move("player_2", "left")
self.my_map.move("player_2", "left")
self.my_map.move("player_1", "right")
self.assertEqual(self.my_map.print_map(), "..##......\n#.##..###.\n#.###.###.\n#..O..###.\n###.#####.\n")
示例10: test_fight1
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)
示例11: TestDungeon
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()
示例12: test_fight_equal
def test_fight_equal(self):
hero_one = Hero("Bron", 100, "DragonSlayer")
orc_one = Orc("Orcy", 150, 1.5)
hero_one.weapon = Weapon("Axe", 20, 0.5)
orc_one.weapon = Weapon("Axe", 20, 0.5)
self.fight_one.simulate_battle()
# both has the same weapon, but the orc has berserc_factor,\
# he should be alive at the end
self.assertTrue(self.orc_one.is_alive())