1
0
Fork 0

add accidental exit protection

This commit is contained in:
Lili (Tlapka) 2022-01-25 14:50:17 +01:00
parent ae6cc86bd4
commit 066c7f3305
1 changed files with 55 additions and 39 deletions

View File

@ -302,6 +302,7 @@ def game_loop():
print("Basic commands are:")
print("(S)tart, (N)ext, (H)elp, (C)heck, (E)xit")
while True:
try:
print("Waiting for your input:")
command = input()
command = command.lower()
@ -345,6 +346,21 @@ def game_loop():
give_hint(game, hint_giver)
else:
print("Unknown command. Enter another command or try (H)elp.")
except EOFError:
print("Unknown command. Enter another command or try (H)elp.")
print("If you want to exit the assistant, please use the `exit` command.")
except KeyboardInterrupt:
print("You sent a keyboard interrupt to the program.")
print("Would you like to exit? yes/no")
confirmation = input()
confirmation = confirmation.lower()
if confirmation in ("y", "yes"):
abort_game(game, hint_giver, flag_checker)
print("Exiting...")
return
else:
print("Not exiting. Continuing normal operation.")
print("Next time, please use the `exit` command to exit.")
if __name__ == "__main__":