diff --git a/p054/poker.py b/p054/poker.py index 73c2bd6..6b7d6af 100644 --- a/p054/poker.py +++ b/p054/poker.py @@ -176,6 +176,8 @@ class Hand: self.__rank = Hand.ONE_PAIR mvalues = [m[0] for m in multiples] self.__values = mvalues + [c.value for c in self.__cards if c.value not in mvalues] + if not self.__rank: + self.__rank = Hand.HIGH_CARD return self.__rank def values(self): @@ -349,6 +351,9 @@ class Player: # Rebuild and re-evaluate hand self.__hand = Hand.create_best_hand([str(c) for c in self.__community_cards + self.__cards]) + def discard(self, index): + self.__cards.pop(index) + self.__hand = Hand.create_best_hand([str(c) for c in self.__community_cards + self.__cards]) def hand(self): return self.__hand def __repr__(self): @@ -376,4 +381,4 @@ if __name__ == '__main__': players = sorted(players, reverse=True) print 'Community', community_cards for player in players: - print player \ No newline at end of file + print player