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]
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)))
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))
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)]
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)
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)]