Beispiel #1
0
    def createSplitDisplay(self, seat, allHands, parent):
        self.deleteSplitDisplay(parent)
        handArray = allHands[seat]
        total_hands = len(handArray)
        if total_hands > 1:
            current_hand_index = self.table.getCurrentHandIndex(seat, allHands)
            x_increment = 0.24
            x_size = (total_hands - 1) * x_increment
            x = -x_size * 0.5
            y = -0.16
            card_y = -0.05
            for h in range(total_hands):
                hand = handArray[h]
                value = PlayingCardGlobals.getBlackjackHandValue(hand)
                scale = 0.375
                length = len(hand)
                card_x_increment = 0.06
                left = card_x_increment * scale * length * -0.5
                for i in range(length):
                    card = PlayingCard.PlayingCardNodePath(
                        'standard', PlayingCardGlobals.Unknown)
                    card.reparentTo(parent)
                    card.setPos(x + left + i * (card_x_increment * scale), 0,
                                card_y)
                    card.setScale(scale)
                    card.setValue(hand[i])
                    card.turnUp()
                    card.show()
                    parent.cardArray.append(card)
                    if h == current_hand_index:
                        color = 1.0
                        card.setColor(color, color, color, 1.0)
                    else:
                        color = 0.6
                        card.setColor(color, color, color, 1.0)

                label = DirectLabel(parent=parent,
                                    relief=None,
                                    text='',
                                    text_align=TextNode.ACenter,
                                    text_scale=0.04,
                                    pos=(x, 0.0, y),
                                    text_fg=(1, 1, 1, 1),
                                    text_shadow=(0, 0, 0, 1))
                label['text'] = str(value)
                label.show()
                parent.labelArray.append(label)
                x += x_increment

        return
 def createSplitDisplay(self, seat, allHands, parent):
     self.deleteSplitDisplay(parent)
     handArray = allHands[seat]
     total_hands = len(handArray)
     if total_hands > 1:
         current_hand_index = self.table.getCurrentHandIndex(seat, allHands)
         x_increment = 0.23999999999999999
         x_size = (total_hands - 1) * x_increment
         x = -x_size * 0.5
         y = -0.16
         card_y = -0.050000000000000003
         for h in range(total_hands):
             hand = handArray[h]
             value = PlayingCardGlobals.getBlackjackHandValue(hand)
             scale = 0.375
             length = len(hand)
             card_x_increment = 0.059999999999999998
             left = card_x_increment * scale * length * -0.5
             for i in range(length):
                 card = PlayingCard.PlayingCardNodePath('standard', PlayingCardGlobals.Unknown)
                 card.reparentTo(parent)
                 card.setPos(x + left + i * card_x_increment * scale, 0, card_y)
                 card.setScale(scale)
                 card.setValue(hand[i])
                 card.turnUp()
                 card.show()
                 parent.cardArray.append(card)
                 if h == current_hand_index:
                     color = 1.0
                     card.setColor(color, color, color, 1.0)
                     continue
                 color = 0.59999999999999998
                 card.setColor(color, color, color, 1.0)
             
             label = DirectLabel(parent = parent, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.040000000000000001, pos = (x, 0.0, y), text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1))
             label['text'] = str(value)
             label.show()
             parent.labelArray.append(label)
             x += x_increment
Beispiel #3
0
    def setTableState(self, hands, allHands):
        for panel in self.playerStatusPanels:
            for card in panel.hand:
                card.hide()

            panel.handNameLabel.hide()
            panel.splitLabel.hide()
            panel.handsLabel.hide()

        self.hands = hands
        for i in range(len(hands)):
            newHand = hands[i]
            guiIndex = self.getGuiIndex(i)
            panel = self.playerStatusPanels[guiIndex]
            hand = panel.hand
            handNameLabel = panel.handNameLabel
            splitLabel = panel.splitLabel
            handsLabel = panel.handsLabel
            for card, newValue in zip(hand, newHand):
                card.show()
                card.setValue(newValue)
                if newValue == PlayingCardGlobals.Unknown:
                    card.turnDown()
                else:
                    card.turnUp()

            self.centerCards(panel, newHand)
            if newHand and PlayingCardGlobals.Unknown not in newHand:
                handValue = PlayingCardGlobals.getBlackjackHandValue(newHand)
                if handValue == 21 and len(newHand) == 2:
                    handArray = allHands[i]
                    total_hands = len(handArray)
                    if total_hands <= 1:
                        handNameLabel['text'] = PLocalizer.BlackjackHand
                    else:
                        handNameLabel['text'] = str(handValue)
                elif handValue > 21:
                    handNameLabel[
                        'text'] = PLocalizer.BlackjackBusted % handValue
                else:
                    handNameLabel['text'] = str(handValue)
                handNameLabel.show()
                if i == self.table.localAvatarSeat:
                    handArray = allHands[i]
                    total_hands = len(handArray)
                    if total_hands > 1:
                        current_hand_index = self.table.getCurrentHandIndex(
                            i, allHands)
                        splitLabel['text'] = PLocalizer.BlackjackHandofHand % (
                            current_hand_index + 1, total_hands)
                        splitLabel.show()
                        hands_text = ''
                        for h in range(current_hand_index):
                            hands_text = hands_text + str(
                                PlayingCardGlobals.getBlackjackHandValue(
                                    handArray[h])) + '   '

                        handsLabel.show()
                        self.createSplitDisplay(i, allHands, handsLabel)
                    self.canSplit = False
                    self.canDoubleDown = False
                    if newHand[0] in self.splitCardsArray:
                        self.splitCardsArray.remove(newHand[0])
                    if handValue >= 21:
                        self.disableAllPlayButtons()
                    else:
                        self.updateSplitAndDoubleDown(newHand)
 def setTableState(self, hands, allHands):
     for panel in self.playerStatusPanels:
         for card in panel.hand:
             card.hide()
         
         panel.handNameLabel.hide()
         panel.splitLabel.hide()
         panel.handsLabel.hide()
     
     self.hands = hands
     for i in range(len(hands)):
         newHand = hands[i]
         guiIndex = self.getGuiIndex(i)
         panel = self.playerStatusPanels[guiIndex]
         hand = panel.hand
         handNameLabel = panel.handNameLabel
         splitLabel = panel.splitLabel
         handsLabel = panel.handsLabel
         for (card, newValue) in zip(hand, newHand):
             card.show()
             card.setValue(newValue)
             if newValue == PlayingCardGlobals.Unknown:
                 card.turnDown()
                 continue
             card.turnUp()
         
         self.centerCards(panel, newHand)
         if newHand and PlayingCardGlobals.Unknown not in newHand:
             handValue = PlayingCardGlobals.getBlackjackHandValue(newHand)
             if handValue == 21 and len(newHand) == 2:
                 handArray = allHands[i]
                 total_hands = len(handArray)
                 if total_hands <= 1:
                     handNameLabel['text'] = PLocalizer.BlackjackHand
                 else:
                     handNameLabel['text'] = str(handValue)
             elif handValue > 21:
                 handNameLabel['text'] = PLocalizer.BlackjackBusted % handValue
             else:
                 handNameLabel['text'] = str(handValue)
             handNameLabel.show()
             if i == self.table.localAvatarSeat:
                 handArray = allHands[i]
                 total_hands = len(handArray)
                 if total_hands > 1:
                     current_hand_index = self.table.getCurrentHandIndex(i, allHands)
                     splitLabel['text'] = PLocalizer.BlackjackHandofHand % (current_hand_index + 1, total_hands)
                     splitLabel.show()
                     hands_text = ''
                     for h in range(current_hand_index):
                         hands_text = hands_text + str(PlayingCardGlobals.getBlackjackHandValue(handArray[h])) + '   '
                     
                     handsLabel.show()
                     self.createSplitDisplay(i, allHands, handsLabel)
                 
                 self.canSplit = False
                 self.canDoubleDown = False
                 if newHand[0] in self.splitCardsArray:
                     self.splitCardsArray.remove(newHand[0])
                 
                 if handValue >= 21:
                     self.disableAllPlayButtons()
                 else:
                     self.updateSplitAndDoubleDown(newHand)
             
         i == self.table.localAvatarSeat