summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swiftstory/board.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/swiftstory/board.py b/swiftstory/board.py
index c9b2aee..31ddd11 100644
--- a/swiftstory/board.py
+++ b/swiftstory/board.py
@@ -1,25 +1,24 @@
import random
+from typing import List, Optional, Tuple
+
+from swiftstory.player import Player
class Board:
''' This class automatically handles the reshuffling of different deck/heap
of cards '''
- def __init__(self):
- # List of tuples:
- # (card_id, card_desc)
- self.white_pick = list()
- self.black_pick = list()
- self.white_recycled = list()
- self.black_recycled = list()
+ def __init__(self) -> None:
+ self.white_pick: List[Tuple[int, str]] = []
+ self.black_pick: List[Tuple[int, str]] = []
+ self.white_recycled: List[Tuple[int, str]] = []
+ self.black_recycled: List[Tuple[int, str]] = []
- self.current_black_card = None
+ self.current_black_card: Optional[Tuple[int, str]] = None
- # List of tuples:
- # ((card_id, card_desc), player)
- self.played_cards = list()
+ self.played_cards: List[Tuple[Tuple[int, str], Player]] = []
- def reveal_next_black_card(self):
+ def reveal_next_black_card(self) -> None:
if self.current_black_card is not None:
self.black_recycled.append(self.current_black_card)
self.current_black_card = None
@@ -33,7 +32,7 @@ class Board:
self.current_black_card = self.black_pick.pop()
- def pick_white_card(self):
+ def pick_white_card(self) -> Tuple[int, str]:
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,13 +42,13 @@ class Board:
return self.white_pick.pop()
- def play_card(self, player, card):
+ def play_card(self, player: Player, card: Tuple[int, str]) -> None:
self.played_cards.append((card, player))
- def shuffle_played_cards(self):
+ def shuffle_played_cards(self) -> None:
random.shuffle(self.played_cards)
- def recycle_played_cards(self):
+ def recycle_played_cards(self) -> None:
self.white_recycled += [i[0] for i in self.played_cards]
self.played_cards = []