added io_card_selection(), define_card_stack()
and added end() and restart() for print statements in clean_input.py
This commit is contained in:
parent
75ce84e094
commit
323f6bce24
|
@ -5,6 +5,7 @@ __credits__ = ""
|
||||||
__email__ = ""
|
__email__ = ""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import quartett
|
||||||
|
|
||||||
|
|
||||||
def io_str(message: str, options: list) -> str:
|
def io_str(message: str, options: list) -> str:
|
||||||
|
@ -30,13 +31,9 @@ def io_str(message: str, options: list) -> str:
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if i == "q":
|
if i == "q":
|
||||||
print(
|
end()
|
||||||
"---------------------\nSpiel wird beendet...\n---------------------")
|
|
||||||
sys.exit()
|
|
||||||
elif i == "r":
|
elif i == "r":
|
||||||
print(
|
restart()
|
||||||
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
|
||||||
quartett.main()
|
|
||||||
else:
|
else:
|
||||||
print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')
|
print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')
|
||||||
|
|
||||||
|
@ -54,12 +51,9 @@ def io_int(message: str) -> int:
|
||||||
unfiltered_input = input(message)
|
unfiltered_input = input(message)
|
||||||
|
|
||||||
if unfiltered_input == "q":
|
if unfiltered_input == "q":
|
||||||
print("---------------------\nSpiel wird beendet...\n---------------------")
|
end()
|
||||||
sys.exit()
|
|
||||||
elif unfiltered_input == "r":
|
elif unfiltered_input == "r":
|
||||||
print(
|
restart()
|
||||||
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
|
||||||
#quartett.main()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
i = int(unfiltered_input)
|
i = int(unfiltered_input)
|
||||||
|
@ -72,43 +66,72 @@ def io_int(message: str) -> int:
|
||||||
except (ValueError, NameError):
|
except (ValueError, NameError):
|
||||||
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
||||||
|
|
||||||
def io_list(message: str, options: list):
|
|
||||||
|
def io_card_selection(message: str):
|
||||||
"""
|
"""
|
||||||
check card selection
|
check card selection
|
||||||
:param message: 1a
|
:param message: Select something...
|
||||||
:param options: [{'id': 3, 'number': 0, 'letter': 'd'}, {'id': 9, 'number': 1, 'letter': 'b'}]
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
card_stack = define_card_stack()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
user_input = input(message)
|
||||||
i = str(input(message))
|
|
||||||
|
|
||||||
except (ValueError, NameError):
|
if user_input[0] in "0123" and user_input[1] in "abcdefgh":
|
||||||
i = 0
|
for c in card_stack:
|
||||||
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
if c["number"] == user_input[0] and c["letter"] == user_input[1]:
|
||||||
|
card = c
|
||||||
|
return card
|
||||||
|
|
||||||
if i in options:
|
elif user_input == "q":
|
||||||
return i
|
end()
|
||||||
|
|
||||||
|
elif user_input == "r":
|
||||||
|
restart()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if i == "q":
|
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
||||||
print(
|
|
||||||
"---------------------\nSpiel wird beendet...\n---------------------")
|
|
||||||
sys.exit()
|
|
||||||
elif i == "r":
|
|
||||||
print(
|
|
||||||
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
|
||||||
quartett.main()
|
|
||||||
else:
|
|
||||||
print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')
|
|
||||||
|
|
||||||
def define_card_stack():
|
def define_card_stack():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
card_stack = []
|
||||||
|
x = 0
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
for l in "abcdefgh":
|
for l in "abcdefgh":
|
||||||
d = {"id": x, "number": i, "letter": l}
|
d = {"id": str(x), "number": str(i), "letter": l}
|
||||||
card_stack.append(d)
|
card_stack.append(d)
|
||||||
x += 1
|
x += 1
|
||||||
|
|
||||||
|
return card_stack
|
||||||
|
|
||||||
|
|
||||||
|
def end():
|
||||||
|
"""
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
print(
|
||||||
|
"---------------------\nSpiel wird beendet...\n---------------------")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def restart():
|
||||||
|
"""
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
print(
|
||||||
|
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
||||||
|
quartett.central_function()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue