mirror of
https://github.com/JonasunderscoreJones/EPR-Gruppenabgabe-07.git
synced 2025-10-23 01:39:18 +02:00
added deal_cards()
This commit is contained in:
parent
b5d23db85b
commit
80c794d8e6
1 changed files with 28 additions and 0 deletions
28
game.py
28
game.py
|
@ -14,5 +14,33 @@ def create_cards():
|
||||||
return card_deck
|
return card_deck
|
||||||
|
|
||||||
|
|
||||||
|
def deal_cards(card_deck:list, players:int, cards_per_player:int):
|
||||||
|
'''
|
||||||
|
Deals cards to players
|
||||||
|
|
||||||
|
input:
|
||||||
|
- card_deck: list
|
||||||
|
list of cards
|
||||||
|
- players: int
|
||||||
|
number of players
|
||||||
|
- cards_per_player: int
|
||||||
|
number of cards per player
|
||||||
|
output:
|
||||||
|
- player_cards: tuple
|
||||||
|
tuple of lists, each list contains the cards of a player
|
||||||
|
'''
|
||||||
|
temp_cards = []
|
||||||
|
for player in range(players):
|
||||||
|
temp_cards.append([])
|
||||||
|
for card in range(cards_per_player):
|
||||||
|
temp_cards[player].append(card_deck.pop(0))
|
||||||
|
while len(temp_cards) < 5:
|
||||||
|
temp_cards.append([])
|
||||||
|
|
||||||
|
return (temp_cards[0], temp_cards[1], temp_cards[2], temp_cards[3], temp_cards[4])
|
||||||
|
|
||||||
|
|
||||||
card_deck = create_cards()
|
card_deck = create_cards()
|
||||||
print(card_deck)
|
print(card_deck)
|
||||||
|
|
||||||
|
print(deal_cards(card_deck, 5, 5))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue