2022-11-18 13:10:08 +00:00
|
|
|
from enum import IntEnum, auto
|
|
|
|
|
|
|
|
from poker.utils.enum import AutoName
|
|
|
|
|
|
|
|
|
2022-11-18 21:00:37 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-11-18 13:10:08 +00:00
|
|
|
class Suit(AutoName):
|
|
|
|
"""Card suit enum."""
|
|
|
|
|
2022-11-18 13:31:23 +00:00
|
|
|
CLUBS = auto()
|
|
|
|
DIAMONDS = auto()
|
|
|
|
HEARTS = auto()
|
|
|
|
SPADES = auto()
|
2022-11-18 13:10:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Value(IntEnum):
|
|
|
|
"""Card value enum."""
|
|
|
|
|
|
|
|
TWO = 2
|
|
|
|
THREE = 3
|
|
|
|
FOUR = 4
|
|
|
|
FIVE = 5
|
|
|
|
SIX = 6
|
|
|
|
SEVEN = 7
|
|
|
|
EIGHT = 8
|
|
|
|
NINE = 9
|
|
|
|
TEN = 10
|
|
|
|
JACK = 11
|
|
|
|
QUEEN = 12
|
|
|
|
KING = 13
|
2022-11-18 21:00:37 +00:00
|
|
|
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
|