def get_game_data(self): ret = super(BlackJackTable, self).get_game_data() ret['game_state'] = self.game_state dealer_cards = self.current_round and self.current_round.dealers_hand.get_cards() or [] dealer_up_cards = [] if self.game_state == consts.GAME_STATE_PLAYING: dealer_up_cards.append(Card.get_face_down()) for card in dealer_cards[1:]: dealer_up_cards.append(card) ret['dealer_up_cards'] = dealer_up_cards all_hands = BlackJackHand.objects.filter(round=self.current_round, dealers_hand=False) for hand in all_hands: player = [s for s in ret['seats'] if s['player_id'] == hand.player_id][0] player['cards'] = hand.get_cards() player['available_actions'] = hand.get_available_actions() return ret
def add_card(self, card): cards = self.get_cards() cards.append(card) self.set_cards(cards) if self.can_split: actions = self.get_available_actions() actions.append('split') self.set_available_actions(actions) self.save() #augment the card data for client if self.dealers_hand: card['dealt_to'] = 'dealer' else: if self.split_from.all().count(): card['split_card'] = True player_id = self.player_id card['dealt_to'] = player_id if (self.dealers_hand and self.num_cards == 1): card.update(Card.get_face_down()) client = Client(data=card, table_id=self.round.table_id, action='deal_card') client.notify()