From 5f41d87403d6e498671c44675af96750c4ae24e9 Mon Sep 17 00:00:00 2001 From: AccidentallyOnPurpose <4935931+AccidentallyOnPurpose@users.noreply.github.com4935931+AccidentallyOnPurpose@users.noreply.github.com> Date: Tue, 24 Dec 2019 10:26:16 +0800 Subject: [PATCH] generated and print suggestion one at a time good idea --- play.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/play.py b/play.py index 7132cb6..c4acdd7 100644 --- a/play.py +++ b/play.py @@ -169,17 +169,13 @@ def play(): if story_manager.story.results else "\nWhat do you do now?" ) + "\n>" - # (cloveranon) can this just be a for loop? - # (AccidentallyOP) yes, and it would look nicer to see them progress, but you might get duplicates - suggested_actions = ai_player.get_actions(action_prompt) - if len(suggested_actions): - suggested_actions_enum = [ - "{}> {}\n".format(i, a) for i, a in enumerate(suggested_actions) - ] - suggested_action = "".join(suggested_actions_enum) - #TODO: check color - colPrint('Suggested actions\n' + suggested_action, colors['selection-value']) - print() + suggested_actions = [] + colPrint('Suggested actions:', colors['selection-value']) + for i in range(settings.getint('action-alternatives')): + suggested_action = ai_player.get_action(action_prompt) + suggested_actions.append(suggested_action) + colPrint('{}> {}'.format(i, suggested_action), colors['selection-value']) + print() if settings.getboolean('console-bell'): print('\x07', end='') @@ -228,6 +224,7 @@ def play(): else: if action == "": action = "" + colPrint("\n>> " + action.lstrip(), colors["transformed-user-text"]) result = story_manager.act(action) colPrint(result, colors["ai-text"]) elif action in [str(i) for i in range(len(suggested_actions))]: