summaryrefslogtreecommitdiff
path: root/swiftstory/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'swiftstory/client.py')
-rw-r--r--swiftstory/client.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/swiftstory/client.py b/swiftstory/client.py
index 28fd6c0..cd5e82a 100644
--- a/swiftstory/client.py
+++ b/swiftstory/client.py
@@ -1,3 +1,5 @@
+""" Module that defines the client class. """
+
import asyncio
import logging
from typing import Optional
@@ -23,6 +25,7 @@ class Client:
self.player: Optional[Player] = None
def join_game(self, game_name: str, lang: Optional[str]) -> str:
+ """ Attempt to join a game and return an answer. """
if self.game is not None:
raise WrongAction('You are already in a game')
@@ -42,6 +45,7 @@ class Client:
return status
def play_white_card(self, card_id: int) -> str:
+ """ Play a card and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -49,6 +53,7 @@ class Client:
return self.game.try_play_card(self.player, card_id)
def pick_black_card(self) -> str:
+ """ Pick a black card (and become the judge) and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -56,6 +61,7 @@ class Client:
return self.game.try_become_judge(self.player)
def collect_cards(self) -> str:
+ """ Collect the played cards and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -63,6 +69,7 @@ class Client:
return self.game.try_collect_cards(self.player)
def designate_card(self, card_id: Optional[int]) -> str:
+ """ Designate the best card and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -70,6 +77,7 @@ class Client:
return self.game.try_designate_card(self.player, card_id)
def view_player_cards(self) -> str:
+ """ View our own cards and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -77,6 +85,7 @@ class Client:
return self.game.try_view_player_cards(self.player)
def view_played_cards(self) -> str:
+ """ View the cards played at this round and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -84,6 +93,7 @@ class Client:
return self.game.try_view_played_cards(self.player)
def view_black_card(self) -> str:
+ """ View the current black card and return an answer. """
if self.game is None:
raise WrongAction('You have to join a game first')
if self.player is None:
@@ -104,6 +114,7 @@ class Client:
asyncio.create_task(f())
def disconnect(self) -> None:
+ """ Detach from the player. """
if self.player is not None:
if self.game is None:
raise ValueError("Disconnect from inexistent game.")