| | 1 | import deck |
| | 2 | |
| | 3 | |
| | 4 | #for all these functions, make sure cards are sorted DESCENDING!!!! |
| | 5 | |
| | 6 | def is_n_kinds(cards): |
| | 7 | highest_n = 0 #greatest num in a row |
| | 8 | current_n = 0 |
| | 9 | highest_card = None #highest card for greatest num in a row |
| | 10 | last = 1 |
| | 11 | for (a,b) in cards[1:] |
| | 12 | |
| | 13 | def is_flush(cards): |
| | 14 | last=cards[0][1] |
| | 15 | flush = True |
| | 16 | for (a,b) in cards[1:]: |
| | 17 | if b != last: |
| | 18 | flush = False |
| | 19 | break |
| | 20 | if flush: return ["flush", cards[0][0]] #return highest card |
| | 21 | else: return None |
| | 22 | |
| | 23 | def is_straight(cards): |
| | 24 | last=cards[0][0] |
| | 25 | straight = True |
| | 26 | for (a,b) in cards[1:]: |
| | 27 | if a != last-1: |
| | 28 | straight = False |
| | 29 | last = a |
| | 30 | break |
| | 31 | if straight: return ["straight", cards[0][0]] #return highest card |
| | 32 | else: return None |
| | 33 | |
| | 34 | |