Skip to content

Commit

Permalink
swap simplenamespaces to dataclasses for cards
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetrucciani committed Mar 8, 2024
1 parent 7082fbd commit 36df038
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
48 changes: 41 additions & 7 deletions gamble/models/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,62 @@

import random
from collections import Counter
from types import SimpleNamespace
from dataclasses import dataclass
from typing import Any
from gamble.errors import InvalidCard


class Suit(SimpleNamespace):
@dataclass
class Suit:
"""
suit namespace class
suit
Args:
name: the name of this suit
char: the ascii character representation for this suit
symbol: the unicode symbol char for this suit
value: the value of the suit
color: the color of the suit
unicode: the unicode id for this suit as an int
"""

name: str
char: str
symbol: str
value: int
color: int
unicode: int


class Value(SimpleNamespace):
@dataclass
class Value:
"""
value namespace class
value
Args:
char: the ascii character representation for this value
name: the name of the card
value: the value of the card as an int
"""

char: str
name: str
value: int

class Rank(SimpleNamespace):

@dataclass
class Rank:
"""
hand ranks namespace class
hand ranks
Args:
value: the integer value of the rank
name: the name of the rank
"""

value: int
name: str


class Card:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gamble"
version = "0.12"
version = "0.13"
description = "a collection of gambling classes/tools"
readme = "README.md"
authors = ["jacobi petrucciani <[email protected]>"]
Expand Down

0 comments on commit 36df038

Please sign in to comment.