-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCards.py
34 lines (27 loc) · 916 Bytes
/
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
import json
class Cards:
# setup member variables
def __init__(self):
# initialize member variables
self.CARDS_IN_A_SUIT = 12
self.all_cards = set()
self.card_values = {}
# create points map for all cards
self.set_card_values()
# create set of all cards
self.all_cards = set(self.card_values.keys())
# creates a points map from the json file
def set_card_values(self):
# load cards and their values from json file
try:
f = open('card_values.json')
self.card_values = json.load(f)[0]
f.close()
except:
print("Cards.py -> Error: Loading card_values.json")
# returns the point value of a card
def get_card_values(self, card):
try:
return self.card_values[card]
except:
return "Cards.py -> Error: Card not found"