summaryrefslogtreecommitdiff
path: root/swiftstory/Client.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-11-01 23:28:07 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-11-01 23:47:25 +0100
commit0fca30bbdac79d8d33e152e7e7116c5ffa1356ca (patch)
treebfcd33f2bd68f220ffad956b07d37002dc06de9f /swiftstory/Client.py
parentd66b6d0115e620f8c12629a5822cf31d3e976a20 (diff)
Add WrongAction exception and use it instaed of returning error
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/Client.py')
-rw-r--r--swiftstory/Client.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/swiftstory/Client.py b/swiftstory/Client.py
index 93aa900..b1a6ae7 100644
--- a/swiftstory/Client.py
+++ b/swiftstory/Client.py
@@ -1,6 +1,7 @@
import asyncio
import logging
+from swiftstory.exception import WrongAction
from swiftstory.Status import error
@@ -14,7 +15,7 @@ class Client:
def join_game(self, game_name, lang):
if self.game is not None:
- return error('You are already in a game')
+ raise WrongAction('You are already in a game')
if lang is None:
lang = 'en'
@@ -29,37 +30,37 @@ class Client:
def play_white_card(self, card_id):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_play_card(self.player, card_id)
def pick_black_card(self):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_become_judge(self.player)
def collect_cards(self):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_collect_cards(self.player)
def designate_card(self, card_id):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_designate_card(self.player, card_id)
def view_player_cards(self):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_view_player_cards(self.player)
def view_played_cards(self):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_view_played_cards(self.player)
def view_black_card(self):
if self.game is None:
- return error('You have to join a game first')
+ raise WrongAction('You have to join a game first')
return self.game.try_view_black_card(self.player)
def register_notification(self, message):