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


Python Hero.weapon方法代码示例

本文整理汇总了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")
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:11,代码来源:test_all.py

示例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())
开发者ID:GalinaDimitrova,项目名称:Hack,代码行数:11,代码来源:fight_test.py

示例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.")
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:63,代码来源:CLI-deprecate.py

示例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")
开发者ID:stilyantanev,项目名称:Dungeons-And-Pythons,代码行数:33,代码来源:main.py

示例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')
开发者ID:IvanAlexandrov,项目名称:HackBulgaria-Tasks,代码行数:33,代码来源:manual_test_dungeon.py


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