| summaryrefslogtreecommitdiff |
path: root/tonkadur_ui.py
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 16:14:54 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 16:14:54 +0200 |
| commit | 48f780650c7d92c945989b45dc781d415c85a21d (patch) | |
| tree | 623f298e233c01e47e6d6422c120f8df23476d84 /tonkadur_ui.py | |
| parent | b6108592b66cc14573e5614aa5c878b71c6be6cb (diff) | |
Adds user prompts, removes address of player_choice.
Diffstat (limited to 'tonkadur_ui.py')
| -rw-r--r-- | tonkadur_ui.py | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/tonkadur_ui.py b/tonkadur_ui.py index 85f91e4..f27efd7 100644 --- a/tonkadur_ui.py +++ b/tonkadur_ui.py @@ -46,6 +46,47 @@ try: break elif (result_category == "display"): print(display_rich_text(result['content'])) + elif (result_category == "prompt_integer"): + while True: + user_input = input( + display_rich_text(result['label']) + + " " + + "[" + + str(result['min']) + + ", " + + str(result['max']) + + "] " + ) + user_input = int(user_input) + if ( + (user_input >= result['min']) + and (user_input <= result['max']) + ): + break + else: + print("Value not within range.") + state.store_integer(user_input) + + elif (result_category == "prompt_string"): + while True: + user_input = input( + display_rich_text(result['label']) + + " " + + "[" + + str(result['min']) + + ", " + + str(result['max']) + + "] " + ) + if ( + (len(user_input) >= result['min']) + and (len(user_input) <= result['max']) + ): + break + else: + print("Input size not within range.") + state.store_string(user_input) + elif (result_category == "assert"): print("Assert failed at line " + str(result['line']) + ":" + str(display_rich_text(result['message']))) print(str(state.memory)) @@ -53,7 +94,7 @@ try: current_choice = 0; for choice in result['choices']: - print(str(current_choice) + ". " + display_rich_text(choice[0])) + print(str(current_choice) + ". " + display_rich_text(choice)) current_choice += 1 user_choice = input("Your choice? ") |


