-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathburaco.py
44 lines (31 loc) · 1.08 KB
/
buraco.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
35
36
37
38
39
40
41
42
43
from deck import Deck
class InvalidNumberOfPlayers(Exception):
def __init__(self):
self.msg = "The number of players must be 2, 3 or 4"
class Buraco(object):
def __init__(self, _players):
if (len(_players) < 2) or (len(_players) > 4):
raise InvalidNumberOfPlayers()
self.players = _players
self.pots = [[],[]]
self.stock = []
self.discard_pile = []
self.let_players_know_me()
self._deal_cards()
self._current_player = self.players[0]
def let_players_know_me(self):
for player in self.players:
player.set_game(self)
def _deal_cards(self):
deck = Deck()
for times in range(11):
self.pots[0].append(deck.get_cards())
self.pots[1].append(deck.get_cards())
for player in self.players:
player.receive_card(deck.get_cards())
self.stock = deck.get_all_cards()
def current_player(self):
return self._current_player
def pop_stock_card(self):
card = self.stock.pop()
return card