diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-12-29 19:21:45 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-12-29 20:06:14 +0100 |
commit | 741f8234edde84dccefcbf5dc0ba3b70c0e016e2 (patch) | |
tree | c6207bfd9c20eeac59bea2ffef5d4fad70108c29 /swiftstory/board.py | |
parent | f5edd5035d06adc7b6bceb1f521b4911706cde0b (diff) |
Add docstrings to all modules
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
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 = [] |