183 lines
6.7 KiB
Plaintext
183 lines
6.7 KiB
Plaintext
>>> import quartett as q
|
|
>>> 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}]
|
|
|
|
|
|
1. pretty_print_deck(players_with_cards, player)
|
|
|
|
Positivtests:
|
|
|
|
>>> q.pretty_print_deck(players_with_cards, 0)
|
|
Dein Deck: ['0b', '3g', '0h', '1b', '0f', '3a', '1f', '0c', '0g', '2a']
|
|
|
|
>>> q.pretty_print_deck(players_with_cards, 1) is None
|
|
True
|
|
|
|
>>> q.pretty_print_deck(players_with_cards, 2) is None
|
|
True
|
|
|
|
Negativtests:
|
|
|
|
>>> q.pretty_print_deck("player", 0)
|
|
Traceback (most recent call last):
|
|
...
|
|
TypeError: string indices must be integers
|
|
|
|
>>> q.pretty_print_deck([0], 1)
|
|
Traceback (most recent call last):
|
|
...
|
|
IndexError: list index out of range
|
|
|
|
---
|
|
|
|
2. steal(active, chosen_player, players_with_cards, player_request)
|
|
|
|
Positivtests:
|
|
|
|
>>> active = 1
|
|
>>> chosen_player = 2
|
|
>>> player_request = {'id': '3', 'number': '0', 'letter': 'd'}
|
|
>>> q.steal(active, chosen_player, players_with_cards, player_request)
|
|
player2 hat die Karte, die player1 haben möchte und sie wandert in sein Deck.
|
|
|
|
>>> active = 0
|
|
>>> chosen_player = 1
|
|
>>> player_request = {'id': '27', 'number': '3', 'letter': 'd'}
|
|
>>> q.steal(active, chosen_player, players_with_cards, player_request)
|
|
player1 hat die Karte, die du haben möchtest und sie wandert in dein Deck.
|
|
|
|
>>> active = 2
|
|
>>> chosen_player = 1
|
|
>>> player_request = {'id': '12', 'number': '1', 'letter': 'e'}
|
|
>>> q.steal(active, chosen_player, players_with_cards, player_request)
|
|
player1 hat die Karte, die player2 haben möchte und sie wandert in sein Deck.
|
|
|
|
Negativtests:
|
|
|
|
>>> active = 2
|
|
>>> chosen_player = 1
|
|
>>> player_request = {'id': '12', 'number': '1', 'letter': 'k'}
|
|
>>> q.steal(active, chosen_player, players_with_cards, player_request)
|
|
Traceback (most recent call last):
|
|
...
|
|
ValueError: {'id': '12', 'number': '1', 'letter': 'k'} is not in list
|
|
|
|
>>> active = 2
|
|
>>> chosen_player = 1
|
|
>>> player_request = {}
|
|
>>> q.steal(active, chosen_player, players_with_cards, player_request)
|
|
Traceback (most recent call last):
|
|
...
|
|
ValueError: {} is not in list
|
|
|
|
---
|
|
|
|
3. drop_cards_help(p, all_quartets)
|
|
|
|
Positivtests:
|
|
|
|
>>> p = players_with_cards[0]
|
|
>>> for i in range(4):
|
|
... p["cards_on_hand"][i]["letter"] = "b"
|
|
>>> all_quartets = []
|
|
>>> q.drop_cards_help(p, all_quartets)
|
|
Du legst das b-Quartett ab...
|
|
|
|
>>> p = players_with_cards[1]
|
|
>>> for i in range(4):
|
|
... p["cards_on_hand"][i]["letter"] = "c"
|
|
>>> q.drop_cards_help(p, all_quartets)
|
|
player1 legt das c-Quartett ab...
|
|
|
|
>>> p = players_with_cards[2]
|
|
>>> for i in range(4):
|
|
... p["cards_on_hand"][i]["letter"] = "d"
|
|
>>> q.drop_cards_help(p, all_quartets)
|
|
player2 legt das d-Quartett ab...
|
|
|
|
Negativtests:
|
|
|
|
>>> p = players_with_cards[0]
|
|
>>> q.drop_cards_help(p, all_quartets) is None
|
|
True
|
|
|
|
>>> p = players_with_cards[1]
|
|
>>> q.drop_cards_help(p, all_quartets) is None
|
|
True
|
|
|
|
---
|
|
|
|
# remove end_screen() from the_winner_is to test it
|
|
4. the_winner_is(players_with_cards, players)
|
|
|
|
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 = ["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!
|
|
|
|
Negativtests:
|
|
|
|
>>> q.the_winner_is(players_with_cards[0], players)
|
|
Traceback (most recent call last):
|
|
...
|
|
KeyError: 0
|
|
|
|
>>> q.the_winner_is(players_with_cards)
|
|
Traceback (most recent call last):
|
|
...
|
|
TypeError: the_winner_is() missing 1 required positional argument: 'players' |