本文整理汇总了Python中hero.Hero.weapon方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.weapon方法的具体用法?Python Hero.weapon怎么用?Python Hero.weapon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.weapon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_print_map_after_battle
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import weapon [as 别名]
def test_print_map_after_battle(self):
hero = Hero("Alan", 1, "Turing")
hero.weapon = Weapon("Stick", 1, 0.1)
self.dungeon.map = "ZSNZ"
self.dungeon.spawn("1", hero)
self.dungeon.spawn_npcs()
self.dungeon.move_player("1", "right")
self.assertEqual(self.dungeon.map, "Z.OZ")
示例2: test_fight_equal
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import weapon [as 别名]
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())
示例3: start
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import weapon [as 别名]
def start():
print("Welcome. Type 'help' for available commands")
exit = False
created = False
loaded_map = False
while exit is False:
full_command = input('--> ').strip().split(' ')
if full_command[0] == 'load_map':
dungeon = Dungeon(full_command[1])
if dungeon.map:
loaded_map = True
elif full_command[0] == 'show_map' and loaded_map:
print(dungeon.print_map())
elif full_command[0] == 'create_hero' and loaded_map:
my_hero = Hero(
full_command[1], int(full_command[2]), full_command[3])
my_hero.weapon = Weapon('Ashbringer', 40, 0.8)
created = True
elif full_command[0] == 'spawn_hero' and loaded_map:
if created is True:
dungeon.spawn(full_command[1], my_hero)
dungeon.spawn_npcs()
else:
print('No created characters.')
elif full_command[0] == 'move' and loaded_map:
if full_command[1] not in dungeon.ingame:
print ('Player name is incorrect.')
elif not dungeon.ingame[full_command[1]].is_alive():
exit = True
return 'Your character is dead. Game over.'
else:
if dungeon.unlocked:
exit = True
return 'Game Over. You have won.'
print(dungeon.move_player(full_command[1], full_command[2]))
to_move = dungeon.get_random_npc()
if not dungeon.ingame[to_move].is_alive():
dungeon.ingame = {
i: dungeon.ingame[i] for i in dungeon.ingame if i != 0}
dungeon.npcs = {i: dungeon.npcs[i]
for i in dungeon.npcs if i != 0}
else:
print(dungeon.move_npc(to_move))
print(dungeon.print_map())
elif full_command[0] == 'heal':
if created and loaded_map:
my_hero.health = my_hero.max_health
else:
print('No created characters.')
elif full_command[0] == 'known_as':
if created and loaded_map:
print (my_hero.known_as())
else:
print('No created characters.')
elif full_command[0] == 'help':
print(helper)
elif full_command[0] == 'exit':
exit = True
else:
print("Invalid command. Type 'help' for available commands.")
示例4: Hero
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import weapon [as 别名]
from hero import Hero
from dungeon import Dungeon
from weapon import Weapon
if __name__ == '__main__':
hero = Hero("Ragnar", "Lothbrok", 20, 100, 2)
knife = Weapon("Knife", 50)
hero.weapon = knife
dungeon = Dungeon.load_map_from_file("level1.txt")
print("Hello, You are in our game! Exit from dungeon, marry to princess!")
print("Move by typing 'l,L(left)', 'r,R(right)', 'u,U(up)', 'd,D(down)'")
print("Attack enemies with f(fight).")
print("GO GO GO HERO!")
print()
dungeon.spawn(hero)
is_loaded_second_map = False
while hero.is_alive() or dungeon.spawn(hero):
dungeon.print_map()
move = input("Choose your move: ")
is_there_gate = False
if move == "W" or move == "w":
is_there_gate = dungeon.move_hero("u")
elif move == "A" or move == "a":
is_there_gate = dungeon.move_hero("l")
示例5: Dungeon
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import weapon [as 别名]
from dungeon import Dungeon
from hero import Hero
from ork import Ork
from weapon import Weapon
d = Dungeon('dungeon.txt')
hero = Hero('Manson', 120, 'Captain')
orc = Ork('FishHead', 100, 1.01)
orc.weapon = Weapon('Axe', 12, 0.2)
hero.weapon = Weapon('Gun', 20, 0.1)
print(hero.known_as() + " IS HERE")
print(d.move("FishHead", 'right'))
d.spawn('Manson', hero)
d.spawn('FishHead', orc)
d.move('Manson', 'right')
d.move('Manson', 'down')
d.move('Manson', 'down')
d.move('Manson', 'down')
d.move('Manson', 'right')
d.move('Manson', 'right')
d.move('Manson', 'right')
d.move('Manson', 'right')
d.move('Manson', 'up')
d.move('Manson', 'up')
d.move('Manson', 'up')
d.move('Manson', 'right')
d.move('FishHead', 'up')
d.move('FishHead', 'up')
d.move('FishHead', 'up')
d.move('FishHead', 'up')
d.move('FishHead', 'left')