summaryrefslogtreecommitdiff
path: root/CAO_Player.py
blob: 91e6351dff4eb78c2eb3472018a118cc989c490d (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
import json

class CAO_Player():
    def __init__(self, client):
        self.cards = {}
        self.next_idx = 0

        self.client = client

        self.score = 0

        self.has_played = False

        self.name = 'default'

    def pop_card(self, card_id):
        return self.cards.pop(card_id)

    def get_has_played(self):
        return self.has_played

    def set_has_played(self, has=True):
        self.has_played = has

    def inc_score(self):
        self.score += 1

    def receive_card(self, card):
        self.cards[self.next_idx] = card
        self.next_idx += 1
        return self.next_idx - 1

    def send_notification(self, obj):
        if self.client is None:
            return

        message = json.dumps({'type': 'notification', 'content': obj})

        self.client.send_notification(message)