-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
42 lines (30 loc) · 1.25 KB
/
player.py
File metadata and controls
42 lines (30 loc) · 1.25 KB
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
import utils
class Player(object):
def __init__(self, name):
self.name = name
self.cards = []
self.blocked = []
def __str__(self):
return self.name
def add_card(self, card):
self.cards.append(card)
self.blocked.append(0)
def block_card(self, idx):
self.blocked[idx] = 1
def get_card_by_idx(self, idx):
return self.cards[idx]
def replace_card(self, new_card, idx):
old_card = self.cards[idx]
self.cards[idx] = new_card
return old_card
def display_all_cards(self, r, ch):
r.publish(ch , utils.construct_message('Displaying all cards for'+self.name, False))
for card in self.cards:
r.publish(ch , utils.construct_message(str(card), False))
def display_first_two_cards(self, r, ch):
r.publish(ch , utils.construct_message('Displaying first two cards ', False))
for card in self.cards[:2]:
r.publish(ch , utils.construct_message(str(card), False))
def display_card_by_idx(self, idx, r, ch):
r.publish(ch , utils.construct_message("Displaying card for player at index"+str(idx), False))
r.publish(ch , utils.construct_message(str(self.cards[idx]), False))