def friend_select(self, username, data): index = int(username[-1]) client = self.clients[index] new_cards = [] for card in data['floor_cards']: new_cards.append(code_to_card(card)) card = data.get('card', None) player = data.get('player', None) round = data.get('round', None) change_bid = data.get('change_bid', None) content = { 'username': username, 'nonce': username, 'reply': client.reply_channel, 'type': data['type'], 'floor-cards': new_cards, } if card is not None: content['card'] = code_to_card(card) if player is not None: content['player'] = player if round is not None: content['round'] = round if change_bid is not None: content['change-bid'] = change_bid client.send_and_consume('gameplay-friend-select', content) self.flush_all()
def floor_card(self, cards): new_cards = [] for card in cards: new_cards.append(code_to_card(card)) room = cache.get('room:test') room['game']['floor_cards'] = new_cards cache.set('room:test', room)
def deal(self, username, cards): new_cards = [] for card in cards: new_cards.append(code_to_card(card)) room = cache.get('room:test') for i, player in enumerate(room['players']): if player['username'] == username: room['players'][i]['cards'] = new_cards break cache.set('room:test', room)
def kill(self, username, kill_card): index = int(username[-1]) client = self.clients[index] content = { 'username': username, 'nonce': username, 'reply': client.reply_channel, 'card': code_to_card(kill_card), } client.send_and_consume('gameplay-kill', content) self.flush_all()
def play(self, username, card, joker_call=None, joker_suit=None): card = code_to_card(card) index = int(username[-1]) client = self.clients[index] content = { 'username': username, 'nonce': username, 'reply': client.reply_channel, 'card': card, } if joker_call: content['joker-call'] = joker_call if joker_suit: content['joker-suit'] = joker_suit client.send_and_consume('gameplay-play', content) self.flush_all()
def code_to_card_bulk(self, cards): new_cards = [] for card in cards: new_cards.append(code_to_card(card)) return new_cards