本文整理汇总了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()