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


Python State.main_menu方法代码示例

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


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

示例1: main

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import main_menu [as 别名]
def main():
    cur_state = State()
    if not cur_state.game_state:
        cur_state.main_menu()

    player = cur_state.game_state['player']
    player_location = player.location

    party = cur_state.game_state['party']
    party_status = False
    for character in party:
        if character.cur_stats['health'] > 0:
            party_status = True

    while party_status:
        current_location = getattr(navigation, player_location.replace(" ", ""))()

        action_input = input('Choose an action: ')
        available_actions = current_location.available_actions()
        found_action = False
        for action in available_actions:
            if action_input.lower() == 'exit':
                sys.exit()

            if (action_input.lower() == action.hotkey.lower()) or \
                    (action_input.lower() in [a.lower() for a in action.alt]):
                os.system('clear')  # For OSX / Linux
                os.system('cls')  # For Windows
                found_action = True
                actions.do_action(action, action.action_class, **action.kwargs)
                break
        if not found_action:
            os.system('clear')  # For OSX / Linux
            os.system('cls')  # For Windows

        cur_state = State()
        cur_state.load_quicksave()
        player = cur_state.game_state['player']
        player_location = player.location
        cur_state.save_game()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:42,代码来源:pyrpg.py


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