Esempio n. 1
0
 def high_card(self,thisHandp,p):
     cfg.whwHands[p] = 0
     cfg.whwCards[p] = [useful.card_2_drawid_conv(useful,thisHandp[i]) 
                                                       for i in range(0,2)]
     if len(thisHandp) > 2:
         cfg.whwCards[p] += [useful.card_2_drawid_conv(useful,thisHandp[j]) 
                                                     for j in range(2,5)]
Esempio n. 2
0
 def four_of_a_kind(self,thisHandp,p):
     self.F,self.foak = 0,[]
     for c in thisHandp:
         if useful.nested_count(useful,thisHandp,c) == 4:
             cfg.whwHands[p] = 7
             self.F = c[0]
             self.foak += [c]
     if self.F > 0:
         cfg.whwCards[p] = [useful.card_2_drawid_conv(useful,self.foak[n]) 
                                                        for n in range(4)]
         self.kicker = [thisHandp[k] for k in range(len(thisHandp)) 
                                  if thisHandp[k] not in self.foak]
         cfg.whwCards[p].append(useful.card_2_drawid_conv(useful,max(self.kicker)))
Esempio n. 3
0
 def two_pairs(self,thisHandp,p):
     self.bar = []
     for c in thisHandp:
         if useful.nested_count(useful,thisHandp,c) == 2:
             self.bar += [c]
     if len(self.bar) >= 4:
         self.bar.sort(reverse=True)
         self.pairs = self.bar[0:4]
         self.r = [thisHandp[i] for i in range(len(thisHandp)) if thisHandp[i] 
                                                        not in self.pairs]
         self.kicker = max(self.r)
         cfg.whwHands[p] = 2
         cfg.whwCards[p] = [useful.card_2_drawid_conv(useful,self.pairs[i]) 
                                            for i in range(4)]
         cfg.whwCards[p].append(useful.card_2_drawid_conv(useful,self.kicker))
Esempio n. 4
0
 def str_flush(self,thisHandp,p):
     self.foo = []
     self.aceCheck = False
     for c in thisHandp:
         if c[1] == cfg.CpFlush[0]:
             self.foo += [c]
             self.aceCheck = True
     # Count whether a players matching suit cards form a 5 card flush.
     if len(self.foo) >=5:
         if self.aceCheck:
             for c in self.foo:
                 if c[0] == 14:
                     self.A1 = [1,cfg.CpFlush[0]]
                     self.A14 = [c]
                     self.foo.append(self.A1)
         self.foo.sort(reverse=True)
         for s in range(0,len(self.foo)-4):
             if self.foo[s][0]-4 == self.foo[s+4][0] and cfg.whwHands[p] != 1:
                 cfg.whwHands[p] = 1
                 if self.A1 in self.foo:
                     # Replace A1 with A14 at the end (duplicate) so that 
                     # the s range includes the ace card
                     self.foo.remove(self.A1)
                     self.foo.append(self.A14)
                 cfg.whwCards[p] = [useful.card_2_drawid_conv
                                (useful,self.foo[s+t]) for t in range(0,5)]
Esempio n. 5
0
 def two_of_a_kind(self,thisHandp,p):
     self.pairs = []
     for c in thisHandp:
         if useful.nested_count(useful,thisHandp,c) == 2:
             self.pairs += [c]
             cfg.whwHands[p] = 1
     if len(self.pairs) == 2:
                 cfg.whwCards[p] = [useful.card_2_drawid_conv(useful,self.pairs[i]) for i in range(2)]
                 self.kicker = [thisHandp[k] for k in range(len(thisHandp)) 
                                     if thisHandp[k] not in self.pairs]
                 self.a = max(self.kicker)
                 self.kicker.remove(self.a)
                 self.b = max(self.kicker)
                 self.kicker.remove(self.b)
                 self.c = max(self.kicker)
                 self.kicker = [self.a, self.b, self.c]
                 cfg.whwCards[p] += [useful.card_2_drawid_conv(useful,self.kicker[j]) for j in range(3)]
Esempio n. 6
0
 def full_house(self,thisHandp,p):
     self.trips = []
     self.pair = []
     self.T = 0
     self.P = 0
     for c in thisHandp:
         if useful.nested_count(useful,thisHandp,c) == 3 and c[0] > self.T:
             self.T = c[0]
     self.trips = [useful.card_2_drawid_conv(useful,thisHandp[i]) for i in 
                       range (len(thisHandp)) if thisHandp[i][0] == self.T]
     for c in thisHandp:
         if (useful.nested_count(useful,thisHandp,c) >= 2 and 
                                         c[0] != self.T and c[0] > self.P):
             self.P = c[0]
     self.pair = [useful.card_2_drawid_conv(useful,thisHandp[i]) for i in 
                       range (len(thisHandp)) if thisHandp[i][0] == self.P]
     if self.T and self.P > 0:
         cfg.whwHands[p] = 6
         cfg.whwCards[p] = self.trips + self.pair[0:2]
Esempio n. 7
0
    def three_of_a_kind(self,thisHandp,p):
        self.T = 0
        self.trips = []
        for c in thisHandp:
            if useful.nested_count(useful,thisHandp,c) == 3:
                self.T = c[0]
        if self.T > 0:
#            print('tripsT=',self.T)
            self.trips = [useful.card_2_drawid_conv(useful,thisHandp[i]) for
                        i in range(len(thisHandp)) if thisHandp[i][0] == self.T]
#        if len(self.trips) > 0:
            cfg.whwHands[p] = 3
            cfg.whwCards[p] = self.trips
            self.kicker = [thisHandp[k] for k in range(len(thisHandp)) 
                              if thisHandp[k][0] != self.T]
            self.a = max(self.kicker)
            self.kicker.remove(self.a)
            self.b = max(self.kicker)
            self.kicker = [self.a, self.b]
            self.bar = [useful.card_2_drawid_conv(useful,self.kicker[i])
                                                      for i in range(2)]
            cfg.whwCards[p].extend(self.bar)
Esempio n. 8
0
 def flush(self,thisHandp,p):
     self.foo = []
     for c in thisHandp:
         if c[1] == cfg.CpFlush[0]:
             self.foo += [c]
     # Count whether a players matching suit cards form a 5 card flush.
     if len(self.foo) >=5:
         self.foo.sort(reverse=True)
         while len(self.foo) > 5:
             # check that pop removes last item ???
             self.foo.pop()
         cfg.whwHands[p] = 5
         cfg.whwCards[p] = [useful.card_2_drawid_conv(useful,self.foo[n])
                                                         for n in range(5)]
Esempio n. 9
0
 def straight(self,thisHandp,p):
     self.foo = thisHandp[:]
     self.A1 = []
     for c in self.foo:
         if c[0] == 14:
             self.A14 = c
             self.A1 = [1,c[1]]
     if len(self.A1) > 0:
         self.foo.append(self.A1)
     for c in self.foo:
         if useful.nested_count(useful,self.foo,c) > 1:
             self.foo.remove(c)
     if len(self.foo) >= 5:
         for s in range(0,len(self.foo)-4):
             if (self.foo[s][0]-4 == self.foo[s+4][0] and 
                                                    cfg.whwHands[p] != 4):
                 cfg.whwHands[p] = 4
                 while self.A1 in self.foo:
                     self.foo.remove(self.A1)
                     self.foo.append(self.A14)
                 cfg.whwCards[p] = [useful.card_2_drawid_conv
                                       (useful,self.foo[t+s]) 
                                         for t in range(0,5)]