summaryrefslogtreecommitdiff
path: root/swiftstory/Board.py
diff options
context:
space:
mode:
Diffstat (limited to 'swiftstory/Board.py')
-rw-r--r--swiftstory/Board.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/swiftstory/Board.py b/swiftstory/Board.py
index 40d3ab7..5176e55 100644
--- a/swiftstory/Board.py
+++ b/swiftstory/Board.py
@@ -2,6 +2,9 @@ import random
class Board:
+ ''' This class automatically handles the reshuffling of different deck/heap
+ of cards '''
+
def __init__(self, white_cards, black_cards):
self.white_pick = white_cards
self.black_pick = black_cards
@@ -17,26 +20,27 @@ class Board:
random.shuffle(self.white_pick)
random.shuffle(self.black_pick)
- def reveal_black_card(self):
- if not self.black_pick:
- self.black_pick = self.black_recycle
+ def reveal_next_black_card(self):
+ if self.current_black_card is not None:
+ self.black_recycled.append(self.current_black_card)
+ self.current_black_card = None
- random.shuffle(self.black_pick)
+ if not self.black_pick:
+ # If we have no more cards in the deck, we need to reform one using
+ # the cards that have been recycled.
+ random.shuffle(self.black_recycled)
- self.black_recycled = []
+ self.black_pick, self.black_recycled = self.black_recycled, list()
self.current_black_card = self.black_pick.pop()
- def recycle_black_card(self):
- self.black_recycled.append(self.current_black_card)
-
def pick_white_card(self):
if not self.white_pick:
- self.white_pick = self.white_recycled
-
- random.shuffle(self.white_pick)
+ # If we have no more cards in the deck, we need to reform one using
+ # the cards that have been recycled.
+ random.shuffle(self.white_recycled)
- self.white_recycled = []
+ self.white_pick, self.white_recycled = self.white_recycled, list()
return self.white_pick.pop()