-
Notifications
You must be signed in to change notification settings - Fork 0
/
deck.py
67 lines (51 loc) · 2.04 KB
/
deck.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import copy
import random
class Deck:
def __init__(self, starting_deck: dict, rejected=[], size: int = 5):
self.output_deck = []
self.output_value = 0
self.rejected = rejected
self.team_size = size
self.available_cards: dict = self.deck_clone(starting_deck)
self.remove_rejected()
self.add_werewolves()
def deck_clone(self, deck):
return copy.deepcopy(deck)
def remove_rejected(self):
for card_name in self.rejected:
try:
del self.available_cards[card_name]
except KeyError:
continue
def add_card(self, card_name: str):
self.output_value += self.available_cards[card_name]['value']
self.output_deck.append(card_name)
self.available_cards[card_name]['quantity'] -= 1
if self.available_cards[card_name]['quantity'] == 0:
del self.available_cards[card_name]
def add_werewolves(self):
number_of_werewolves = self.team_size // 3
for _ in range(number_of_werewolves):
self.add_card('Werewolf')
# Returns whether we added the second mason or not
def check_masons(self) -> bool:
if self.output_deck.count('Mason') == 1:
if not 'Mason' in self.available_cards.keys():
return False
self.add_card('Mason')
return True
# Checks to see if a Seer is present
def check_seers(self) -> bool:
grown_up_seers = {'Seer','Mystic Seer', 'Aura Seer'}
need_seers = {'Apprentice Seer'}
# Our deck has seer requirements if this passes
if bool(set(self.output_deck) & need_seers):
# Check to see if any other seers are present
if not bool(set(self.output_deck) & grown_up_seers):
# We will add a plain seer
#TODO: Make this a function
if not 'Seer' in self.available_cards.keys():
return False
self.add_card('Seer')
return True
return False