| 8 | pass |
| 9 | |
| 10 | class Player(): |
| 11 | |
| 12 | def __init__(self, name): |
| 13 | self.id = None |
| 14 | self.name = name |
| 15 | self.type = 'Human' |
| 16 | self.hand = Hand() |
| 17 | self.legalCards = [] |
| 18 | self.wildCards = [] |
| 19 | self.valueChangeCards = [] |
| 20 | self.zeroCards = [] |
| 21 | self.canSkip = False |
| 22 | self.canReverse = False |
| 23 | self.canDrawTwo = False |
| 24 | self.canDrawFour = False |
| 25 | self.canValueChange = False |
| 26 | self.drew = False |
| 27 | self.scrollMax = 0 |
| 28 | self.points = 0 |
| 29 | self.forceDraw = 0 |
| 30 | |
| 31 | def addCard(self, card): |
| 32 | self.drew = True |
| 33 | if self.forceDraw > 0: |
| 34 | self.forceDraw -= 1 |
| 35 | self.drew = False |
| 36 | self.hand.addCard(card) |
| 37 | |
| 38 | def beginTurn(self): |
| 39 | self.drew = False |
| 40 | |
| 41 | def didDraw(self): |
| 42 | return self.drew |
| 43 | |
| 44 | def getLegalCards(self, color, value, zeroChange=False): |
| 45 | self.canSkip = False |
| 46 | self.canReverse = False |
| 47 | self.canDrawTwo = False |
| 48 | self.canDrawFour = False |
| 49 | self.canValueChange = False |
| 50 | self.canZeroChange = False |
| 51 | self.legalCards = [] |
| 52 | self.wildCards = [] |
| 53 | self.valueChangeCards = [] |
| 54 | self.zeroCards = [] |
| 55 | plusFours = [] |
| 56 | for card in self.hand: |
| 57 | if card.isWild(): |
| 58 | if card.getValue() == '+4': |
| 59 | plusFours.append(card) |
| 60 | else: |
| 61 | self.wildCards.append(card) |
| 62 | elif zeroChange and card.isZero(): |
| 63 | self.canZero = True |
| 64 | self.zeroCards.append(card) |
| 65 | elif card.getColor() == color or card.getValue() == value: |
| 66 | if card.getColor() != color: |
| 67 | self.canValueChange = True |