diff --git a/clean_input.py b/clean_input.py index a0faa71..b2c8062 100644 --- a/clean_input.py +++ b/clean_input.py @@ -71,3 +71,44 @@ 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): + """ + check card selection + :param message: 1a + :param options: [{'id': 3, 'number': 0, 'letter': 'd'}, {'id': 9, 'number': 1, 'letter': 'b'}] + :return: + """ + while True: + try: + i = str(input(message)) + + except (ValueError, NameError): + i = 0 + 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: + """ + for i in range(4): + for l in "abcdefgh": + d = {"id": x, "number": i, "letter": l} + card_stack.append(d) + x += 1 \ No newline at end of file diff --git a/quartett.py b/quartett.py index df3b22b..ab44225 100644 --- a/quartett.py +++ b/quartett.py @@ -12,16 +12,10 @@ def central_function(): active = 0 # contains index of the active player card_stack, players_with_cards, players = initialize() - # print(card_stack) - # print(str(len(card_stack))) - # - # print(players_with_cards) - # print(str(len(players_with_cards))) - # - # print(players) - #while deckP1 and deckP2 and deckP3 not empty: - # round(..., players_with_cards, players) + ..., players_with_cards, players = initialize()[0], initialize()[1], initialize()[2] + while deckP1 and deckP2 and deckP3 not empty: + round(..., players_with_cards, players) # TO DO implement active_player rotation @@ -95,9 +89,9 @@ def initialize(): # Add list of dicts (cards) to players players_with_cards.append({"player": players[i], "cards_on_hand": cards_of_player}) + return card_stack, players_with_cards, players -central_function() ''' players_with_cards = [ {'player': 'player0', 'cards_on_hand': [{'id': 13, 'number': 1, 'letter': 'f'},