gamble

gamble module

class gamble.BlackJackDeck(num_decks: int = 8)[source]

Bases: gamble.models.cards.MultiDeck

a standard blackjack shoe

Parameters:

num_decks (int) – the number of standard decks to combine into this blackjack shoe

class gamble.Card(value: gamble.models.cards.Value = Value(char='A', name='ace', value=1), suit: gamble.models.cards.Suit = Suit(name='spades', char='S', symbol='♠', value=0, color=0, unicode=127136))[source]

Bases: object

playing card model

Parameters:
class Suits[source]

Bases: object

card suit enum

classmethod all() list[gamble.models.cards.Suit][source]

get all suits in this enum

Returns:

a list of the suit objects

Return type:

list[gamble.models.cards.Suit]

classmethod dict() dict[str, gamble.models.cards.Suit][source]

dict of char -> Suit

Returns:

a dictionary of all the card values

Return type:

dict[str, gamble.models.cards.Suit]

class Values[source]

Bases: object

card value enum

classmethod all() list[gamble.models.cards.Value][source]

get all suits

Returns:

a list of all the values in this enum

Return type:

list[gamble.models.cards.Value]

classmethod dict() dict[str, gamble.models.cards.Value][source]

dict of char -> Value

Returns:

a dictionary of card characters to their Value representations

Return type:

dict[str, gamble.models.cards.Value]

__eq__(other: object) bool[source]

equal to dunder method

Parameters:

other (object) – another card to compare against

Returns:

true if this card is the same as other

Return type:

bool

__ge__(other: gamble.models.cards.Card) bool[source]

greater than or equal to dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is greater than or equal to other

Return type:

bool

__gt__(other: gamble.models.cards.Card) bool[source]

greater than dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is greater than other

Return type:

bool

__le__(other: gamble.models.cards.Card) bool[source]

less than or equal to dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if less than or equal to other

Return type:

bool

__lt__(other: gamble.models.cards.Card) bool[source]

less than dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is less than other

Return type:

bool

__repr__() str[source]

representation of this card

Returns:

a repr of this card

Return type:

str

__str__() str[source]

string representation of this card

Returns:

a string of this card

Return type:

str

property color: int

returns the color of the card

Returns:

the color enum int for this card

property full_name: str

returns the full name for this card

Returns:

the full name of this card

classmethod get(text: str) gamble.models.cards.Card[source]

get a card by text representation

Parameters:

text (str) – a string representation of a card value and suit

Returns:

the created card, if the string was valid

Return type:

gamble.models.cards.Card

property is_black: bool

is_black property

Returns:

if this card is in a black suit

property is_red: bool

is_red property

Returns:

if this card is in a red suit

property unicode: str

get the fun little unicode card for this card

Returns:

the nice looking unicode char for the suit of this card

class gamble.Course(name: str, holes: list[gamble.models.golf.Hole])[source]

Bases: object

a golf course object

Parameters:
  • name (str) – the name of this golf course

  • holes (list[gamble.models.golf.Hole]) – a list of holes in this golf course

class gamble.Deck(cards: list[gamble.models.cards.Card] | None = None, shuffle: bool = True, default_draw_count: int = 1)[source]

Bases: object

playing card deck model

Parameters:
  • cards (list[gamble.models.cards.Card] | None) – a list of cards for this deck

  • shuffle (bool) – if we should start with the deck shuffled

  • default_draw_count (int) –

__contains__(item: object) bool[source]

dunder contains method

Parameters:

item (object) – the item to check for in this deck

Returns:

true if this deck contains the given object

Return type:

bool

__getitem__(index: int) gamble.models.cards.Card[source]

get the card at the given index in the deck

Returns:

the card at the given index

Parameters:

index (int) –

Return type:

gamble.models.cards.Card

__repr__() str[source]

term representation of a deck

Returns:

a repr representation of this deck

Return type:

str

__str__() str[source]

string representation of a deck

Returns:

a string representation of this deck

Return type:

str

property bottom: gamble.models.cards.Card

the bottom card of the deck

Returns:

a card off the bottom of the deck

property cards_left: int

number of cards left in the deck

Returns:

the number of cards left

clear() None[source]

clear the deck of all cards

Return type:

None

default_deck(cards: list[gamble.models.cards.Card]) None[source]

load the standard 52 cards into the given set of cards

Parameters:

cards (list[gamble.models.cards.Card]) –

Return type:

None

draw(times: int = -1) gamble.models.cards.Card | list[gamble.models.cards.Card][source]

draws the given number of cards from the deck

Parameters:

times (int) – the number of times to draw

Returns:

a card or list of cards drawn

Return type:

gamble.models.cards.Card | list[gamble.models.cards.Card]

draw_hand(size: int = 5) gamble.models.cards.Hand[source]

draw a hand from this deck

Parameters:

size (int) – the size of hand to draw

Returns:

a hand object of size size

Return type:

gamble.models.cards.Hand

shuffle(times: int = 1) None[source]

shuffle the deck

Parameters:

times (int) – the number of times to shuffle the deck

Return type:

None

property top: gamble.models.cards.Card

the top card of the deck

Returns:

a card off the top of the deck

class gamble.Dice(init_string: str = '2d6', rigged_factor: int = -1)[source]

Bases: object

a group of die objects

Parameters:
  • init_string (str) – a d-notation string representing a set of dice

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

__repr__() str[source]

dunder repr method

Returns:

the repr representation of this set of dice

Return type:

str

__str__() str[source]

dunder str method

Returns:

the string representation of this set of dice

Return type:

str

create_die(sides: int, rigged_factor: int = -1) gamble.models.dice.Die | gamble.models.dice.RiggedDie[source]

helper to create dice

Parameters:
  • sides (int) – the number of sides on a die

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

Returns:

A Die object that can be rigged

Return type:

gamble.models.dice.Die | gamble.models.dice.RiggedDie

property max: int

the max value these dice can roll

Returns:

the max for these dice + bonuses

max_of(num_rolls: int = 2) tuple[int, list[int]][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

a tuple with the max value rolled by the dice, and the dice rolls

Return type:

tuple[int, list[int]]

property min: int

the min value these dice can roll

Returns:

the min for these dice + bonuses

min_of(num_rolls: int = 2) tuple[int, list[int]][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

a tuple with the min value rolled by the dice, and the dice rolls

Return type:

tuple[int, list[int]]

property parts: list[gamble.models.dice.Die | int]

listing of the parts of this roll + bonuses

Returns:

a list of the parts of this dice calculation

roll() int[source]

roll the dice

Returns:

the value rolled by this dice

Return type:

int

roll_many(num_rolls: int = 2) list[int][source]

roll dice multiple times

Parameters:

num_rolls (int) – the number of times to roll the dice

Returns:

list of values rolled by these dice

Return type:

list[int]

class gamble.Die(sides: int = 6)[source]

Bases: object

a single die object

Parameters:

sides (int) – the number of sides to this die

__ge__(other: gamble.models.dice.Die) bool[source]

dunder greater than or equal to method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is bigger than or equal to the other die

Return type:

bool

__gt__(other: gamble.models.dice.Die) bool[source]

dunder greater than method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is bigger than the other die

Return type:

bool

__le__(other: gamble.models.dice.Die) bool[source]

dunder less than or equal to method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is smaller than or equal to the other die

Return type:

bool

__lt__(other: gamble.models.dice.Die) bool[source]

dunder less than method

Parameters:

other (gamble.models.dice.Die) – another Die instance

Returns:

true if this die is smaller than the other die

Return type:

bool

__repr__() str[source]

dunder repr method

Returns:

the repr representation of this die

Return type:

str

__str__() str[source]

dunder str method

Returns:

the string representation of this die

Return type:

str

property max: int

the max value this die can roll

Returns:

the max for this die

property min: int

the min value this die can roll

Returns:

the min for this die

property net_sides: int

the raw max sides * multiplier

Returns:

the non-absolute value of this die’s sides

roll() int[source]

roll the die

Returns:

the value rolled by this die

Return type:

int

class gamble.EuchreDeck(**_: Any)[source]

Bases: gamble.models.cards.Deck

deck specifically for euchre

Parameters:

_ (Any) –

class gamble.Group(course: gamble.models.golf.Course, players: list[gamble.models.golf.Player])[source]

Bases: object

a golf group object

Parameters:
class gamble.Hand(cards: list[gamble.models.cards.Card])[source]

Bases: object

playing card hand model

Parameters:

cards (list[gamble.models.cards.Card]) – a list of card objects for this hand

class Ranks[source]

Bases: object

hand ranks for poker

__gt__(other: gamble.models.cards.Hand) bool[source]

greater than dunder method

Parameters:

other (gamble.models.cards.Hand) – another hand to compare against

Returns:

true if this hand is greater than the other

Return type:

bool

__len__() int[source]

dunder len method

Returns:

the number of cards in this hand

Return type:

int

__lt__(other: gamble.models.cards.Hand) bool[source]

less than dunder method

Parameters:

other (gamble.models.cards.Hand) – another hand to compare against

Returns:

true if this hand is less than the other

Return type:

bool

__repr__() str[source]

repr of the hand

Returns:

this hand as repr

Return type:

str

__str__() str[source]

string representation of the hand

Returns:

this hand as a string

Return type:

str

classmethod get(text: str) gamble.models.cards.Hand[source]

get a hand by text representations

Parameters:

text (str) – a text representation of a hand

Returns:

a hand, if the string was valid

Return type:

gamble.models.cards.Hand

property is_flush: bool

check if the hand is a flush

Returns:

true if flush

property is_four_of_a_kind: bool

check if the hand is four of a kind

Returns:

true if four of a kind

property is_full_house: bool

check if the hand is a full house

Returns:

true if full house

property is_one_pair: bool

check if the hand contains one pair

Returns:

true if is one pair

property is_royal_flush: bool

check if the hand is a royal flush

Returns:

true if royal flush

property is_straight: bool

check if the hand is a straight

Returns:

true if straight

property is_straight_flush: bool

check if the hand is a straight flush

Returns:

true if straight flush

property is_three_of_a_kind: bool

check if the hand is three of a kind

Returns:

true if is three of a kind

property is_two_pair: bool

check if the hand contains two pair

Returns:

true if is two pair

property rank: gamble.models.cards.Rank

get the rank of this hand

Returns:

a rank object representing the rank of this hand

class gamble.Hole(tee: int, yards: int, par: int, handicap: int)[source]

Bases: object

a golf hole object

Parameters:
  • tee (int) –

  • yards (int) –

  • par (int) –

  • handicap (int) –

__init__(tee: int, yards: int, par: int, handicap: int) None[source]

hole constructor

Parameters:
  • tee (int) – the tee number for this hole

  • yards (int) – the number of yards from tee to hole

  • par (int) – the par for this hole

  • handicap (int) – the handicap value for this hole

Return type:

None

class gamble.MultiDeck(num_decks: int = 2)[source]

Bases: gamble.models.cards.Deck

deck consisting of multiple standard decks

Parameters:

num_decks (int) – the number of standard decks to combine into one deck

class gamble.Player(name: str, handicap: int)[source]

Bases: object

a golf player object

Parameters:
  • name (str) – the name of the player

  • handicap (int) – the handicap of the player

class gamble.Rank(value: int, name: str)[source]

Bases: object

hand ranks

Parameters:
  • value (int) – the integer value of the rank

  • name (str) – the name of the rank

class gamble.RiggedDie(sides: int = 6, rigged_factor: int = 50)[source]

Bases: gamble.models.dice.Die

a die with a modifier to roll in the top 3 per the percentage passed in

Parameters:
  • sides (int) – the number of sides to this die

  • rigged_factor (int) – int from 0-100 to manipulate the die into a high roll

roll() int[source]

sometime override supers die roll depending on the rigged_factor

Returns:

the value rolled by this die

Return type:

int

class gamble.Suit(name: str, char: str, symbol: str, value: int, color: int, unicode: int)[source]

Bases: object

suit

Parameters:
  • name (str) – the name of this suit

  • char (str) – the ascii character representation for this suit

  • symbol (str) – the unicode symbol char for this suit

  • value (int) – the value of the suit

  • color (int) – the color of the suit

  • unicode (int) – the unicode id for this suit as an int

class gamble.Value(char: str, name: str, value: int)[source]

Bases: object

value

Parameters:
  • char (str) – the ascii character representation for this value

  • name (str) – the name of the card

  • value (int) – the value of the card as an int

Modules

gamble.errors

custom exceptions and error handling

gamble.models

models submodule for gamble