-
Notifications
You must be signed in to change notification settings - Fork 0
/
card_deck.py
34 lines (27 loc) · 946 Bytes
/
card_deck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import random
from card import Card, CardName
from exceptions import CardDeckIsEmptyException
card_counts = {
CardName.SODA: 35,
CardName.MUSCAT_OTTONEL: 22,
CardName.GREY_FRIAR: 16,
CardName.ZOLD_VELTELLINI: 10,
CardName.BREAD_AND_DRIPPING: 5,
CardName.WATER_SPILL: 5,
CardName.TIP: 5,
CardName.GLASS_BREAK: 4,
CardName.MIDDLE_FINDER: 4
}
# TODO: count punishment card counts as it is not stated anywhere
class CardDeck:
cards: list[Card]
def __init__(self) -> None:
self.cards = []
for card_name, card_count in card_counts.items():
for _ in range(card_count):
self.cards.append(Card(name=card_name))
random.shuffle(self.cards)
def draw(self) -> Card:
if len(self.cards) == 0:
raise CardDeckIsEmptyException("There are no more cards left in the deck!")
return self.cards.pop(0)