aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-29 23:39:38 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-29 23:39:38 +0200
commit1609330b4e4a1ad1e3ed26db75efdab5f9729663 (patch)
tree34a9d9021087eeea0110df78034057deecabb2fc
parenta42ff0878d5862a598618cf6d06e89b9176f0914 (diff)
downloadtonkadur-python-interpreter-1609330b4e4a1ad1e3ed26db75efdab5f9729663.zip
tonkadur-python-interpreter-1609330b4e4a1ad1e3ed26db75efdab5f9729663.tar.bz2
Improves rich text display.
-rw-r--r--tonkadur_ui.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tonkadur_ui.py b/tonkadur_ui.py
index 5c1a6fa..de1001e 100644
--- a/tonkadur_ui.py
+++ b/tonkadur_ui.py
@@ -17,6 +17,22 @@ parser.add_argument(
help = 'Wyrd JSON file to load.',
)
+def display_rich_text (rich_text):
+ str_content = ""
+
+ if (not (rich_text['effect'] is None)):
+ str_content += "{(" + str(rich_text['effect']) + ") "
+
+ for c in rich_text['content']:
+ if (isinstance(c, str)):
+ str_content += c
+ else:
+ str_content += display_rich_text(c)
+
+ if (not (rich_text['effect'] is None)):
+ str_content = "}"
+ return str_content
+
args = parser.parse_args()
state = tonkadur.Tonkadur(args.world_file)
@@ -29,15 +45,15 @@ try:
print("Program ended")
break
elif (result_category == "display"):
- print(result['content'])
+ print(display_rich_text(result['content']))
elif (result_category == "assert"):
- print("Assert failed at line " + str(result['line']) + ":" + str(result['message']))
+ print("Assert failed at line " + str(result['line']) + ":" + str(display_rich_text(result['message'])))
print(str(state.memory))
elif (result_category == "resolve_choices"):
current_choice = 0;
for choice in result['choices']:
- print(str(current_choice) + ". " + ''.join(choice[0]['content']))
+ print(str(current_choice) + ". " + display_rich_text(choice[0]))
current_choice += 1
user_choice = input("Your choice? ")