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 1282c0e..93502bd 100644 --- a/swiftstory/Game.py +++ b/swiftstory/Game.py @@ -28,7 +28,7 @@ class Game: random.shuffle(self.board.white_pick) random.shuffle(self.board.black_pick) - async def try_join(self, client): + def try_join(self, client): if len(self.players) >= 10: return error('too many players in this game') @@ -52,7 +52,7 @@ class Game: for p in self.players: if p is not player: - await p.send_notification({'op': 'player_joined_game'}) + p.register_notification({'op': 'player_joined_game'}) cards = [(idx, desc) for idx, (_, desc) in player.cards.items()] @@ -66,7 +66,7 @@ class Game: return success({'cards': cards, 'game_state': state}) - async def try_become_judge(self, player): + 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') @@ -78,12 +78,12 @@ class Game: for p in self.players: if p is not player: - await p.send_notification({'op': 'judge_designed'}) + p.register_notification({'op': 'judge_designed'}) return self.try_view_black_card(player) - async def try_play_card(self, player, card_id): + def try_play_card(self, player, card_id): if self.state is not self.WAITING_COLLECTION: return error('Who asked you to play now ?!') @@ -101,12 +101,12 @@ class Game: self.board.play_card(player, card) - await self.judge.send_notification({'op': 'card_played'}) + self.judge.register_notification({'op': 'card_played'}) return success({'card_id': card_id}) - async def try_collect_cards(self, player): + 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 !?') @@ -120,12 +120,12 @@ class Game: for p in self.players: if p is not player: - await p.send_notification({'op': 'cards_collected'}) + p.register_notification({'op': 'cards_collected'}) return self.try_view_played_cards(player) - async def try_designate_card(self, player, card_id): + def try_designate_card(self, player, card_id): if self.state is not self.WAITING_DESIGNATION: return error('Not now, moron !') @@ -143,7 +143,7 @@ class Game: except IndexError: return error('Invalid card') - await winner.inc_score() + winner.inc_score() # put the cards back in the deck self.board.recycle_played_cards() @@ -153,7 +153,7 @@ class Game: if p.has_played: idx = p.receive_card(self.board.pick_white_card()) - await p.send_notification({ + p.register_notification({ 'op': 'received_card', 'content': { 'card': { @@ -168,7 +168,7 @@ class Game: for p in self.players: if p is not player: - await p.send_notification({'op': 'judge_needed'}) + p.register_notification({'op': 'judge_needed'}) self.state = self.WAITING_NEW_JUDGE @@ -191,19 +191,19 @@ class Game: return error('The black card has not been revealed yet') - async def disconnect(self, player): + def disconnect(self, player): player.client = None if self.judge is player: self.judge = None for p in self.players: - await p.send_notification({'op': 'judge_needed'}) + p.register_notification({'op': 'judge_needed'}) for card, p in self.board.played_cards: p.receive_card(card) - await p.send_notification({ + p.register_notification({ 'op': 'received_card', 'content': { 'card': { |