| 72 | |
| 73 | |
| 74 | class Hand: |
| 75 | def __init__(self): |
| 76 | self.hand = [] |
| 77 | |
| 78 | def __str__(self): |
| 79 | return string_list_join("Hand", self.hand) |
| 80 | |
| 81 | def add_card(self, card): |
| 82 | self.hand.append(card) |
| 83 | |
| 84 | def get_value(self): |
| 85 | var = [] |
| 86 | self.hand_value = 0 |
| 87 | for card in self.hand: |
| 88 | card = str(card) |
| 89 | if card[1] in VALUES: |
| 90 | self.hand_value += VALUES[card[1]] |
| 91 | var.append(card[1]) |
| 92 | if "A" not in var: |
| 93 | return self.hand_value |
| 94 | if self.hand_value + 10 <= 21: |
| 95 | return self.hand_value + 10 |
| 96 | else: |
| 97 | return self.hand_value |
| 98 | |
| 99 | def draw(self, canvas, pos): |
| 100 | for card in self.hand: |
| 101 | card = str(card) |
| 102 | Card(card[0], card[1]).draw(canvas, pos) |
| 103 | pos[0] += 36 |
| 104 | |
| 105 | |
| 106 | class Deck: |