2020-12-09 11:24:01 +01:00
|
|
|
"""clean_input"""
|
|
|
|
|
2020-12-10 10:13:16 +01:00
|
|
|
import sys
|
2020-12-17 11:27:28 +01:00
|
|
|
import game
|
2020-12-09 11:24:01 +01:00
|
|
|
|
2020-12-17 11:27:28 +01:00
|
|
|
|
|
|
|
# message needs to be a string that is printed for user instruction. options is a list of viable inputs
|
|
|
|
def io(message: str, options: list) -> str:
|
|
|
|
while True:
|
2020-12-09 11:24:01 +01:00
|
|
|
try:
|
|
|
|
i = str(input(message))
|
|
|
|
|
|
|
|
except (ValueError, NameError):
|
|
|
|
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
|
|
|
|
|
|
|
if i in options:
|
2020-12-17 11:27:28 +01:00
|
|
|
return i
|
2020-12-09 11:24:01 +01:00
|
|
|
break
|
2020-12-10 10:13:16 +01:00
|
|
|
|
2020-12-09 11:24:01 +01:00
|
|
|
else:
|
2020-12-17 11:27:28 +01:00
|
|
|
# try:
|
|
|
|
# print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')
|
|
|
|
#
|
|
|
|
# except(i == 'q' or i == 'r'):
|
|
|
|
#
|
|
|
|
# if i == 'q':
|
|
|
|
# print("Spiel wird beendet...")
|
|
|
|
# sys.exit()
|
|
|
|
#
|
|
|
|
# if i == 'r':
|
|
|
|
# print("Spiel wird neu gestartet...")
|
|
|
|
# game.main()
|
|
|
|
if i == "q":
|
|
|
|
print("Spiel wird beendet...")
|
|
|
|
sys.exit()
|
|
|
|
elif i == "r":
|
|
|
|
print("Spiel wird neu gestartet...")
|
|
|
|
game.main()
|
|
|
|
else:
|
|
|
|
print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')
|