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


Python Player.get_room方法代码示例

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


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

示例1: valid_arrow_shot

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
def valid_arrow_shot(Player, cave_list, shoot_list, done):
    arrow_path = []
    arrow_room = 0
    arrow_room += Player.get_room()
    # Loop to run through length of shoot list
    for i in range(len(shoot_list)):
        for item in cave_list:
            # Boolean to grab room connections for arrow
            if arrow_room == item.get_value():
                arrow_path = item.get_connection()
        # Boolean to see if arrow shot was correct
        if shoot_list[i] not in arrow_path:
            print("Shot failed")
            return False
        else:
            arrow_room = shoot_list[i]
            print("Shot succeeded")

    # Check if Wumpus was shot by arrow
    for item in cave_list:
        if item.get_wumpus():
            if shoot_list[-(len(shoot_list))] == item.get_value():
                print("You shot the Wumpus, You win the game!")
                done = True

    return True
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:28,代码来源:start_game.py

示例2: teleport_check

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
def teleport_check(Player, cave_list):
    copy_cave = cave_list[:]
    for item in cave_list:
        if item.get_bat() == True:
            while item.get_value() == Player.get_room():
                copy_cave.remove(item)
                random_cave = random.choice(copy_cave)
                Player.set_room(random_cave.get_value())
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:10,代码来源:htw_game.py

示例3: game_over_check

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
def game_over_check(Player, cave_list):
    for item in cave_list:
        if item.get_value() == Player.get_room():
            if item.get_pit():
                print("You triggered a pit, game over")
                return True
            if item.get_wumpus():
                print("You got eaten by the Wumpus, game over")
                return True
    return False
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:12,代码来源:offline.py

示例4: warning_message_check

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
def warning_message_check(Player, cave_list):
    connecting_room = []
    for item in cave_list:
        if item.get_value() == Player.get_room():
            connecting_room = item.get_connection()

    for i in range(len(connecting_room)):
        for item in cave_list:
            if item.get_value() == connecting_room[i]:
                if item.get_pit():
                    item.pit_warning()
                if item.get_bat():
                    item.bat_warning()
                if item.get_wumpus():
                    item.wumpus_warning()
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:17,代码来源:start_game.py

示例5: get_player_route

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
def get_player_route(Player, cave_list):   
    for item in cave_list:
        if item.get_value() == Player.get_room():
            return item.get_connection()
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:6,代码来源:start_game.py

示例6: bat_generation

# 需要导入模块: import Player [as 别名]
# 或者: from Player import get_room [as 别名]
bat_generation(cave_list, cave_list_copy)
wumpus_generation(cave_list, cave_list_copy)
player_start(cave_list, spawn_list)


# Game done variable
done = False

print('\n', "If at anytime you wish to quit, type quit or q\n")
warning_message_check(Player, cave_list)
 
# Game Loop
while not done:
    # Variable to store what rooms the player can connect to
    room_connection = get_player_route(Player, cave_list)
    print("You are in Room:", Player.get_room(), end=" ")
    print("You can travel to:", room_connection)
    
    print("You can shoot an arrow or move: ")
    # Gather user input if moving or shooting
    decision=input("Which would you like to do?: ")
    print()
    if (decision.lower() == "quit" or decision == "q"):
        done = True
    # If choice was to move, get input
    if (decision.lower() == "move" or decision == "m"):
        user_input = int(input("Which room would you like to travel to? "))
        # check to see if user input was a correct room to travel
        if (user_input not in room_connection):
            continue
        # Set Player's current room to user input
开发者ID:Jds95,项目名称:ciss465-HTW,代码行数:33,代码来源:offline.py


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