From 741f8234edde84dccefcbf5dc0ba3b70c0e016e2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 29 Dec 2021 19:21:45 +0100 Subject: Add docstrings to all modules Signed-off-by: Olivier Gayot --- swiftstory/board.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'swiftstory/board.py') 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 = [] -- cgit v1.2.3