summaryrefslogtreecommitdiff
path: root/CAO_Board.py
blob: 0fd595b06b9c400bce613b5c4c8bba86c5e14ba0 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
import random

class CAO_Board():
    def __init__(self, white_cards, black_cards):
        self.white_pick = white_cards
        self.black_pick = black_cards

        self.white_recycled = []
        self.black_recycled = []

        self.current_black_card = None

        # tupple of cards / player currently being played
        self.played_cards = []

        random.shuffle(self.white_pick)
        random.shuffle(self.black_pick)

    def reveal_black_card(self):
        if not self.black_pick:
            self.black_pick = self.black_recycle

            random.shuffle(self.black_pick)

            self.black_recycled = []

        card = self.black_pick.pop()

        self.current_black_card = card

    def recycle_black_card(self):
        self.black_recycled.append(self.current_black_card)

    def pick_white_card(self):
        if not self.white_pick:
            self.white_pick = self.white_recycled

            random.shuffle(self.white_pick)

            self.white_recycled = []

        card = self.white_pick.pop()

        return card

    def play_card(self, player, card):
        self.played_cards.append((card, player))

    def shuffle_played_cards(self):
        random.shuffle(self.played_cards)

    def recycle_played_cards(self):
        self.white_recycled += [i[0] for i in self.played_cards]

        self.played_cards = []