diff options
Diffstat (limited to 'swiftstory/board.py')
-rw-r--r-- | swiftstory/board.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/swiftstory/board.py b/swiftstory/board.py index 31ddd11..01082e4 100644 --- a/swiftstory/board.py +++ b/swiftstory/board.py @@ -1,3 +1,5 @@ +""" This module defines the Board class. """ + import random from typing import List, Optional, Tuple @@ -9,6 +11,7 @@ class Board: of cards ''' def __init__(self) -> None: + """ Initializer for the board. """ self.white_pick: List[Tuple[int, str]] = [] self.black_pick: List[Tuple[int, str]] = [] self.white_recycled: List[Tuple[int, str]] = [] @@ -19,6 +22,8 @@ class Board: self.played_cards: List[Tuple[Tuple[int, str], Player]] = [] def reveal_next_black_card(self) -> None: + """ Fetch the next black card and reveal it. The current card (if any) + moves to the recycling heap. """ if self.current_black_card is not None: self.black_recycled.append(self.current_black_card) self.current_black_card = None @@ -33,6 +38,7 @@ class Board: self.current_black_card = self.black_pick.pop() def pick_white_card(self) -> Tuple[int, str]: + """ Fetch and return the next white card. """ if not self.white_pick: # If we have no more cards in the deck, we need to reform one using # the cards that have been recycled. @@ -43,12 +49,15 @@ class Board: return self.white_pick.pop() def play_card(self, player: Player, card: Tuple[int, str]) -> None: + """ Add a card to the played cards for this round. """ self.played_cards.append((card, player)) def shuffle_played_cards(self) -> None: + """ Shuffle the heap of played cards. """ random.shuffle(self.played_cards) def recycle_played_cards(self) -> None: + """ Move the played cards to the recycling heap of white cards. """ self.white_recycled += [i[0] for i in self.played_cards] self.played_cards = [] |