Пример #1
0
    def new_hand(self,newDeck):

        cfg.thisHand,handStr = [], []
        cfg.whwHands = [[]]*8
        cfg.whwCards = [[]]*8
        cfg.theBigReveal = []

        random.shuffle(cfg.newDeck)
                    
        # Generate 8x player thisHand list.
        cfg.thisHand = [[cfg.newDeck[q]] + [cfg.newDeck[q+8]] for q in range(0,8)]

        cfg.community = [cfg.newDeck[16], cfg.newDeck[17], cfg.newDeck[18], cfg.newDeck[19], cfg.newDeck[20]]
        cfg.thisHand.append(cfg.community)
        self.communityStr = [useful.card_2_png_conv(self,cfg.newDeck[c]) for c in range(16,21)]
 
        # Generate a list of cardname.jpeg strings to represent thisHand list,
        # for reading by drawDeal, using cardStrings() func.
        # e.g cardString = ['7Clubs.png', '2Hearts.png', '5Hearts.png',etc] 
        cfg.cardString = [useful.card_2_png_conv(self,cfg.newDeck[c]) for c in range(0,21)]
        print('newDeck =',cfg.newDeck[0:21])
        print('cardString =',cfg.cardString)


        cfg.card0 = pyglet.resource.image(str(cfg.cardString[0]))
        cfg.card1 = pyglet.resource.image(str(cfg.cardString[1]))
        cfg.card2 = pyglet.resource.image(str(cfg.cardString[2]))
        cfg.card3 = pyglet.resource.image(str(cfg.cardString[3]))
        cfg.card4 = pyglet.resource.image(str(cfg.cardString[4]))
        cfg.card5 = pyglet.resource.image(str(cfg.cardString[5]))
        cfg.card6 = pyglet.resource.image(str(cfg.cardString[6]))
        cfg.card7 = pyglet.resource.image(str(cfg.cardString[7]))

        cfg.card8 = pyglet.resource.image(str(cfg.cardString[8]))
        cfg.card9 = pyglet.resource.image(str(cfg.cardString[9]))
        cfg.card10 = pyglet.resource.image(str(cfg.cardString[10]))
        cfg.card11 = pyglet.resource.image(str(cfg.cardString[11]))
        cfg.card12 = pyglet.resource.image(str(cfg.cardString[12]))
        cfg.card13 = pyglet.resource.image(str(cfg.cardString[13]))
        cfg.card14 = pyglet.resource.image(str(cfg.cardString[14]))
        cfg.card15 = pyglet.resource.image(str(cfg.cardString[15]))

        cfg.card16 = pyglet.resource.image('b2fv.png')
        cfg.card17 = pyglet.resource.image('b2fv.png')
        cfg.card18 = pyglet.resource.image('b2fv.png')
        cfg.card19 = pyglet.resource.image('b2fv.png')
        cfg.card20 = pyglet.resource.image('b2fv.png')

        cfg.label_message = 'Shuffling the deck...'
#        cfg.label = pyglet.text.Label('Shuffling the deck...',
#                              font_name='Myriad Pro Cond',
#                              font_size=24,
#                              x=512, y=22,
#                              anchor_x='center', anchor_y='center',
#                              batch=main_batch)
        """ Run chk_3_com_suited only once at newDeck phase """ 
        useful.chk_3_com_suited(useful,cfg.newDeck)
Пример #2
0
    def on_your_backs(self,whwHands,whwCards):
        # Identify highest int in whwHands list.
        print('cfg.whwHands',cfg.whwHands)
        self.topHand = max(cfg.whwHands)
        self.whwCardStrings = []
        self.strippedwhwCS = []
        self.theBigReveal_IDs = []
        # Gen list of P indexes, if P's whwHand == topHand on the deck 
        self.playersWithTopHand = [n for n in range(8) if cfg.whwHands[n] 
                                                         == self.topHand]
        print('playersWithTopHand', self.playersWithTopHand)

        # Convert whwCard list of ids in to cards for P's with topHand
        for i in self.playersWithTopHand:
            self.foo = []
            self.bar = []
            for c in cfg.whwCards[i]:
                self.foo = useful.drawid_2_card_conv(useful,c)
                self.bar += [self.foo]
            self.whwCardStrings += [self.bar]
        print('whwCardStringsALL =',self.whwCardStrings)

        # Gen a list of whwCardStrings stripped of suit
        for w in self.whwCardStrings:
            fooA = []
            for x in w:
                fooA += [x[0]]
            self.strippedwhwCS += [fooA]
        print('strwhwCS =',self.strippedwhwCS)

        # Identify 'best of the best' hand from P's with topHand and 
        # check for duplicate top 5 cards (for split pot).  
        self.botb = max(self.strippedwhwCS)
        print('botb =',self.botb)
        self.winners = [self.playersWithTopHand[w]
                        for w in range (len(self.playersWithTopHand))
                        if self.strippedwhwCS[w] == self.botb]

        self.HandTypeStrings = ['a High Card',
                                'Two of a Kind',
                                'Two Pairs',
                                'Three of a Kind',
                                'a Straight',
                                'a Flush',
                                'a Full House',
                                'Four of a Kind',
                                'a Straight Flush',
                                'a Royal Flush']
        if len(self.winners) == 1:
            for y in cfg.whwCards[self.winners[0]]:
                self.barB = useful.card_2_png_conv(useful,useful.drawid_2_card_conv(useful,y))
                cfg.theBigReveal += [self.barB]
                self.theBigReveal_IDs += ['cfg.'+ y]

            self.label = ('Take down! Player '
                          + str(int(self.winners[0]) + 1) 
                          + ' is the Winner, with ' 
                          + str(self.HandTypeStrings[self.topHand]))
            print(self.label)
            cfg.label_message = self.label
#            cfg.label = pyglet.text.Label(self.label,
#                                          font_name='Myriad Pro Cond',
#                                          font_size=24,
#                                          x=512, y=22,
#                                          anchor_x='center', anchor_y='center')
        else:
            self.winnersUp = []
            for x in self.winners:
                self.winnersUp += [int(x)+1]
#                self.fooB = []
                for y in cfg.whwCards[x]:
                    self.fooB = useful.card_2_png_conv(useful,useful.drawid_2_card_conv(useful,y))
                    cfg.theBigReveal += [self.fooB]
                    if y not in self.theBigReveal_IDs:
                        self.theBigReveal_IDs += ['cfg.'+ y]
            self.label = ('Split Pot! Players '
                         + str(self.winnersUp)
                         + ' are the Winners, with '
                         + str(self.HandTypeStrings[self.topHand]))
            print(self.label)
            cfg.label_message = self.label
#            cfg.label = pyglet.text.Label(self.label,
#                                      font_name='Myriad Pro Cond',
#                                      font_size=24,
#                                      x=512, y=22,
#                                      anchor_x='center', anchor_y='center')
        print(cfg.theBigReveal)
        
        if 'cfg.card0' not in self.theBigReveal_IDs:
            cfg.card0 = pyglet.resource.image('b2fv.png')
        if 'cfg.card1' not in self.theBigReveal_IDs:
            cfg.card1 = pyglet.resource.image('b2fv.png')
        if 'cfg.card2' not in self.theBigReveal_IDs:
            cfg.card2 = pyglet.resource.image('b2fv.png')
        if 'cfg.card3' not in self.theBigReveal_IDs:        
            cfg.card3 = pyglet.resource.image('b2fv.png')
        if 'cfg.card4' not in self.theBigReveal_IDs:        
            cfg.card4 = pyglet.resource.image('b2fv.png')
        if 'cfg.card5' not in self.theBigReveal_IDs:        
            cfg.card5 = pyglet.resource.image('b2fv.png')
        if 'cfg.card6' not in self.theBigReveal_IDs:        
            cfg.card6 = pyglet.resource.image('b2fv.png')
        if 'cfg.card7' not in self.theBigReveal_IDs:        
            cfg.card7 = pyglet.resource.image('b2fv.png')
           
        if 'cfg.card8' not in self.theBigReveal_IDs:        
            cfg.card8 = pyglet.resource.image('b2fv.png')
        if 'cfg.card9' not in self.theBigReveal_IDs:        
            cfg.card9 = pyglet.resource.image('b2fv.png')
        if 'cfg.card10' not in self.theBigReveal_IDs:        
            cfg.card10 = pyglet.resource.image('b2fv.png')
        if 'cfg.card11' not in self.theBigReveal_IDs:        
            cfg.card11 = pyglet.resource.image('b2fv.png')
        if 'cfg.card12' not in self.theBigReveal_IDs:        
            cfg.card12 = pyglet.resource.image('b2fv.png')
        if 'cfg.card13' not in self.theBigReveal_IDs:        
            cfg.card13 = pyglet.resource.image('b2fv.png')
        if 'cfg.card14' not in self.theBigReveal_IDs:        
            cfg.card14 = pyglet.resource.image('b2fv.png')
        if 'cfg.card15' not in self.theBigReveal_IDs:        
            cfg.card15 = pyglet.resource.image('b2fv.png')

        if 'cfg.card16' not in self.theBigReveal_IDs:        
            cfg.card16 = pyglet.resource.image('b2fv.png')
        if 'cfg.card17' not in self.theBigReveal_IDs:        
            cfg.card17 = pyglet.resource.image('b2fv.png')
        if 'cfg.card18' not in self.theBigReveal_IDs:        
            cfg.card18 = pyglet.resource.image('b2fv.png')
        if 'cfg.card19' not in self.theBigReveal_IDs:        
            cfg.card19 = pyglet.resource.image('b2fv.png')
        if 'cfg.card20' not in self.theBigReveal_IDs:        
            cfg.card20 = pyglet.resource.image('b2fv.png')