def getGroupsOfSuits(self, hand): allGroupsOfSuites = [] groupOfSameSuite = Hand() hand.sort() previousSuit = "" for card in hand.getHand(): if card[0] == previousSuit: groupOfSameSuite.append(card) else: if groupOfSameSuite.size() > 0: allGroupsOfSuites.append(groupOfSameSuite.copy()) groupOfSameSuite.clear() groupOfSameSuite.append(card) previousSuit = card[0] allGroupsOfSuites.append(groupOfSameSuite.copy()) return allGroupsOfSuites
def dealCards(self,noOfCards,noOfHands): hands=[] allCards = False if noOfCards == 0: noOfCards = math.floor(self.deck.size()/noOfHands) allCards = True for handIndex in range(0,noOfHands): hand = Hand() for counter in range(noOfCards): hand.append(self.deck.dealACard()) hands.append(hand.copy()) if allCards: counter = 0 while self.deck.size() > 0: hands[counter].append(self.deck.dealACard()) counter = (counter +1) % noOfHands return hands
def getRuns(self, hand): allRuns = [] currentRun = Hand() previousSuit = "" previousFace = 0 hand.sort() hand.convertFacesToNumbers() for card in hand.getHand(): if card[0] == previousSuit and int(card[1:3]) == previousFace + 1: currentRun.append(card) else: if currentRun.size() > 1: currentRun.convertNumbersToFaces() allRuns.append(currentRun.copy()) currentRun.clear() currentRun.append(card) previousSuit = card[0] previousFace = int(card[1:3]) hand.convertNumbersToFaces() return allRuns