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__ = ""
|
||||
|
||||
import sys
|
||||
import quartett
|
||||
|
||||
|
||||
def io_str(message: str, options: list) -> str:
|
||||
|
@ -30,13 +31,9 @@ def io_str(message: str, options: list) -> str:
|
|||
|
||||
else:
|
||||
if i == "q":
|
||||
print(
|
||||
"---------------------\nSpiel wird beendet...\n---------------------")
|
||||
sys.exit()
|
||||
end()
|
||||
elif i == "r":
|
||||
print(
|
||||
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
||||
quartett.main()
|
||||
restart()
|
||||
else:
|
||||
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)
|
||||
|
||||
if unfiltered_input == "q":
|
||||
print("---------------------\nSpiel wird beendet...\n---------------------")
|
||||
sys.exit()
|
||||
end()
|
||||
elif unfiltered_input == "r":
|
||||
print(
|
||||
"---------------------\nSpiel wird neu gestartet...\n---------------------")
|
||||
#quartett.main()
|
||||
restart()
|
||||
|
||||
try:
|
||||
i = int(unfiltered_input)
|
||||
|
@ -72,43 +66,72 @@ def io_int(message: str) -> int:
|
|||
except (ValueError, NameError):
|
||||
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
|
||||
:param message: 1a
|
||||
:param options: [{'id': 3, 'number': 0, 'letter': 'd'}, {'id': 9, 'number': 1, 'letter': 'b'}]
|
||||
:param message: Select something...
|
||||
:return:
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
i = str(input(message))
|
||||
card_stack = define_card_stack()
|
||||
|
||||
except (ValueError, NameError):
|
||||
i = 0
|
||||
while True:
|
||||
user_input = input(message)
|
||||
|
||||
if user_input[0] in "0123" and user_input[1] in "abcdefgh":
|
||||
for c in card_stack:
|
||||
if c["number"] == user_input[0] and c["letter"] == user_input[1]:
|
||||
card = c
|
||||
return card
|
||||
|
||||
elif user_input == "q":
|
||||
end()
|
||||
|
||||
elif user_input == "r":
|
||||
restart()
|
||||
|
||||
else:
|
||||
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
|
||||
|
||||
if i in options:
|
||||
return i
|
||||
|
||||
else:
|
||||
if i == "q":
|
||||
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():
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
card_stack = []
|
||||
x = 0
|
||||
for i in range(4):
|
||||
for l in "abcdefgh":
|
||||
d = {"id": x, "number": i, "letter": l}
|
||||
d = {"id": str(x), "number": str(i), "letter": l}
|
||||
card_stack.append(d)
|
||||
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