From adb149e8585d3753d7db0294237ad155123e2587 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Fri, 18 Nov 2022 13:10:08 +0000 Subject: feat: Implement card and hand domain models --- poker/constants.py | 33 +++++++++++++++++++++++++++++++++ poker/models.py | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 poker/constants.py create mode 100644 poker/models.py (limited to 'poker') diff --git a/poker/constants.py b/poker/constants.py new file mode 100644 index 0000000..3eeebff --- /dev/null +++ b/poker/constants.py @@ -0,0 +1,33 @@ +from enum import IntEnum, auto + +from poker.utils.enum import AutoName + + +class Suit(AutoName): + """Card suit enum.""" + + CLUBS: auto() + DIAMONDS: auto() + HEARTS: auto() + SPADES: auto() + + +class Value(IntEnum): + """Card value enum.""" + + ACE = 1 + TWO = 2 + THREE = 3 + FOUR = 4 + FIVE = 5 + SIX = 6 + SEVEN = 7 + EIGHT = 8 + NINE = 9 + TEN = 10 + JACK = 11 + QUEEN = 12 + KING = 13 + + + diff --git a/poker/models.py b/poker/models.py new file mode 100644 index 0000000..e62df17 --- /dev/null +++ b/poker/models.py @@ -0,0 +1,16 @@ +from pydantic import BaseModel, Field + +from poker.constants import Suit, Value + + +class Card(BaseModel): + """Card domain model class.""" + + suit: Suit + value: Value + + +class Hand(BaseModel): + """Hand domain model class.""" + + cards: list[Card] = Field(..., min_length=5, max_length=5) -- cgit v1.2.3