-
Notifications
You must be signed in to change notification settings - Fork 2
/
cards.py
40 lines (32 loc) · 1.06 KB
/
cards.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
import numpy as np
import constants
class Cards:
def __init__(self, items):
self.deck = list(map(lambda item : self.transformCard(item), items))
np.random.shuffle(self.deck)
#Reinitialize the given deckType(Community or Chance) using only the cards specified and in the order specified
def reinit(self,deckType,cardIds):
self.deck = [ deckType[id] for id in cardIds ]
def transformCard(self,item):
card = {}
#Type:
#1 = Money to/from the bank
#2 = Money to/from other players
#3 = Change position to self.position
#4 = Get out of Jail free
#5 = Pay for each house self.money and for each hotel, self.money2
#6 = Advance to nearest Railroad
#7 = Advance to nearest Utility
#8 = Go back 3 spaces
card['id'] = item['id']
card['content'] = item['content']
card['type'] = item['type']
card['position'] = item['position']
card['money'] = item['money']
card['money2'] = item['money2']
return card
def draw_card(self):
drawn_card = self.deck.pop(0)
if drawn_card['type'] is not 4:
self.deck.append(drawn_card)
return drawn_card