diff options
author | Paul Harrison <paul@harrison.sh> | 2022-11-18 21:00:37 +0000 |
---|---|---|
committer | Paul Harrison <paul@harrison.sh> | 2022-12-15 16:02:14 +0000 |
commit | d924e39608861362e08c5e3706ff46a7a1af919b (patch) | |
tree | 93a3db318a4f46fed2a545afea8474f7193d7308 /poker/constants.py | |
parent | 5393e7b79939f7da36d55570af3374cef2db2d51 (diff) |
feat: Get hand rank
Method to get rank of a given hand.
Diffstat (limited to 'poker/constants.py')
-rw-r--r-- | poker/constants.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/poker/constants.py b/poker/constants.py index 04a8b34..e0a7348 100644 --- a/poker/constants.py +++ b/poker/constants.py @@ -3,6 +3,21 @@ from enum import IntEnum, auto from poker.utils.enum import AutoName +class Rank(IntEnum): + """Poker rank enum.""" + + ROYAL_FLUSH = 1 + STRAIGHT_FLUSH = 2 + FOUR_OF_A_KIND = 3 + FULL_HOUSE = 4 + FLUSH = 5 + STRAIGHT = 6 + THREE_OF_A_KIND = 7 + TWO_PAIR = 8 + PAIR = 9 + HIGH_CARD = 10 + + class Suit(AutoName): """Card suit enum.""" @@ -15,7 +30,6 @@ class Suit(AutoName): class Value(IntEnum): """Card value enum.""" - ACE = 1 TWO = 2 THREE = 3 FOUR = 4 @@ -28,3 +42,12 @@ class Value(IntEnum): JACK = 11 QUEEN = 12 KING = 13 + ACE = 14 + + def __str__(self) -> str: + """Return string representation.""" + if self.value in [1, 11, 12, 13]: + out: str = self.name.lower() + else: + out = str(self.value) + return out |