diff options
Diffstat (limited to 'swiftstory/Game.py')
-rw-r--r-- | swiftstory/Game.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/swiftstory/Game.py b/swiftstory/Game.py index 5e0961c..7e7da09 100644 --- a/swiftstory/Game.py +++ b/swiftstory/Game.py @@ -26,7 +26,7 @@ class Game(): self.board = Board(white_pick, black_pick) - def try_join(self, client): + async def try_join(self, client): if len(self.players) >= 10: return error('too many players in this game') @@ -50,7 +50,7 @@ class Game(): for p in self.players: if p is not player: - p.send_notification({'op': 'player_joined_game'}) + await p.send_notification({'op': 'player_joined_game'}) cards = self.__view_player_cards(player) @@ -64,7 +64,7 @@ class Game(): return success({'cards': cards, 'game_state': state}) - def try_become_judge(self, player): + async def try_become_judge(self, player): if self.state is not self.WAITING_NEW_JUDGE: # TODO what if the judge has quit ? return error('Someone is judge already') @@ -76,12 +76,12 @@ class Game(): for p in self.players: if p is not player: - p.send_notification({'op': 'judge_designed'}) + await p.send_notification({'op': 'judge_designed'}) return self.try_view_black_card(player) - def try_play_card(self, player, card_id): + async def try_play_card(self, player, card_id): if self.state is not self.WAITING_COLLECTION: return error('Who asked you to play now ?!') @@ -99,12 +99,12 @@ class Game(): self.board.play_card(player, card) - self.judge.send_notification({'op': 'card_played'}) + await self.judge.send_notification({'op': 'card_played'}) return success({'card_id': card_id}) - def try_collect_cards(self, player): + async def try_collect_cards(self, player): if self.state is not self.WAITING_COLLECTION: return error('Do you think it\'s the moment for colletion !?') @@ -118,12 +118,12 @@ class Game(): for p in self.players: if p is not player: - p.send_notification({'op': 'cards_collected'}) + await p.send_notification({'op': 'cards_collected'}) return self.try_view_played_cards(player) - def try_designate_card(self, player, card_id): + async def try_designate_card(self, player, card_id): if self.state is not self.WAITING_DESIGNATION: return error('Not now, moron !') @@ -141,7 +141,7 @@ class Game(): except IndexError: return error('Invalid card') - winner.inc_score() + await winner.inc_score() # put the cards back in the deck self.board.recycle_played_cards() @@ -153,7 +153,7 @@ class Game(): card_idx = p.cards[idx] card_desc = self.white_desc[card_idx] - p.send_notification({ + await p.send_notification({ 'op': 'received_card', 'content': { 'card': { @@ -169,7 +169,7 @@ class Game(): for p in self.players: if p is not player: - p.send_notification({'op': 'judge_needed'}) + await p.send_notification({'op': 'judge_needed'}) self.state = self.WAITING_NEW_JUDGE @@ -205,7 +205,7 @@ class Game(): return error('The black card has not been revealed yet') - def disconnect(self, player): + async def disconnect(self, player): player.client = None if self.judge is player: @@ -213,14 +213,14 @@ class Game(): self.judge = None for p in self.players: - p.send_notification({'op': 'judge_needed'}) + await p.send_notification({'op': 'judge_needed'}) for card, p in self.board.played_cards: idx = p.receive_card(card) card_idx = p.cards[idx] card_desc = self.white_desc[card_idx] - p.send_notification({ + await p.send_notification({ 'op': 'received_card', 'content': { 'card': { |