renamed tests to tests.txt and did some formatting

master
Steinadler 2 years ago
parent 463886551b
commit a2fcec03f2
  1. 7
      clean_input.py
  2. 13
      quartett.py
  3. 47
      tests.txt

@ -141,10 +141,3 @@ def restart():
print(
"---------------------\nSpiel wird neu gestartet...\n---------------------")
quartett.central_function()

@ -86,7 +86,8 @@ def round(card_stack, players_with_cards, players, active, complete_card_stack,
print('Folgende Spieler stehen zur Verfügung:')
print(players_without_active)
chosen_player = players.index(clean_input.io_str(
'Welchen Spieler möchtest du nach einer Karte fragen? ', players_without_active))
'Welchen Spieler möchtest du nach einer Karte fragen? ',
players_without_active))
else:
chosen_player = 1
@ -341,7 +342,7 @@ def the_winner_is(players_with_cards, players):
temp = 1
winners = []
# all potential winners are saved in the winners-list
# all potential winners are saved in the winners-list
# (in case there is more than one)
for i in range(len(players)):
winners.append(0)
@ -354,7 +355,7 @@ def the_winner_is(players_with_cards, players):
if temp == dropped_quartets:
winners[i] = dropped_quartets
# winners then functions as a template
# winners then functions as a template
# to print all the players' names who have won
print("")
for i in range(len(winners)):
@ -368,6 +369,10 @@ def the_winner_is(players_with_cards, players):
def end_screen():
"""
Shows the end screen.
:return: None
"""
clean_input.io_str("Möchten Sie das Spiel beenden oder ein neues Spiel starten? "
"Drücken Sie 'q' zum Beenden oder 'r', "
"um ein neues Spiel zu starten...", [])
@ -377,5 +382,5 @@ def end_screen():
if __name__ == "__main__":
# remove end_screen() from the_winner_is() if you want to run tests
# import doctest
# doctest.testfile("tests")
# doctest.testfile("tests.txt")
central_function()

@ -2,9 +2,25 @@
>>> import clean_input as c
>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number': '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0', 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0', 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1', 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0', 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'}, {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'}, {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'}, {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'}, {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'}, {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}], 'quartet': 1},
... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'}, {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'}, {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'}, {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'}, {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'}, {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
... 'quartet': 1},
... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
1. pretty_print_deck(players_with_cards, player)
@ -116,21 +132,40 @@ True
Positivtests:
>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number': '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0', 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0', 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1', 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0', 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'}, {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'}, {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'}, {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'}, {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'}, {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}], 'quartet': 1},
... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'}, {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'}, {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'}, {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'}, {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'}, {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
... 'quartet': 1},
... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
>>> players = ["player0", "player1", "player2"]
>>> q.the_winner_is(players_with_cards, players)
<BLANKLINE>
player2 hat das Spiel gewonnen!
>>> players_with_cards[1]["quartet"] = 2
>>> q.the_winner_is(players_with_cards, players)
<BLANKLINE>
player1 hat das Spiel gewonnen!
player2 hat das Spiel gewonnen!
>>> players_with_cards[0]["quartet"] = 2
>>> q.the_winner_is(players_with_cards, players)
<BLANKLINE>
Du hast das Spiel gewonnen!
player1 hat das Spiel gewonnen!
player2 hat das Spiel gewonnen!
Loading…
Cancel
Save