haive.games.core.game.containers.deck¶

Deck classes for card games in the game framework.

This module defines the Deck container type and related classes for card games.

Classes¶

Card

Simple Card class for illustration.

Deck

A deck of cards.

StandardPlayingCardDeck

A standard 52-card playing card deck.

Module Contents¶

class haive.games.core.game.containers.deck.Card¶

Bases: game_framework.pieces.base.GamePiece

Simple Card class for illustration.

flip()¶

Flip the card face up/down.

Return type:

None

class haive.games.core.game.containers.deck.Deck¶

Bases: game_framework.containers.base.GamePieceContainer[C]

A deck of cards.

This represents a collection of cards that can be drawn, shuffled, and dealt.

deal(num_players, cards_per_player)¶

Deal cards to multiple players.

Parameters:
  • num_players (int) – Number of players to deal to

  • cards_per_player (int) – Number of cards per player

Returns:

List of lists, where each inner list contains a player’s cards

Return type:

list[list[C]]

discard(card)¶

Add a card to the discard pile.

Parameters:

card (C) – Card to discard

Return type:

None

draw()¶

Draw the top card and set its face up/down based on deck configuration.

Returns:

The drawn card, or None if deck is empty

Return type:

C | None

draw_bottom()¶

Draw the bottom card.

Returns:

The bottom card, or None if deck is empty

Return type:

C | None

insert(card, position)¶

Insert a card at a specific position.

Parameters:
  • card (C) – Card to insert

  • position (int) – Position to insert at (0 for top, len(self.pieces) for bottom)

Raises:

ValueError – If position is out of bounds

Return type:

None

peek_bottom(count=1)¶

Look at bottom cards without drawing.

Parameters:

count (int) – Number of cards to peek at

Returns:

List of cards from the bottom

Return type:

list[C]

peek_top(count=1)¶

Look at top cards without drawing.

Parameters:

count (int) – Number of cards to peek at

Returns:

List of cards from the top

Return type:

list[C]

place_on_bottom(card)¶

Place a card on the bottom of the deck.

Parameters:

card (C) – Card to place

Return type:

None

recycle_discards(shuffle=True)¶

Move all cards from discard pile back into the deck.

Parameters:

shuffle (bool) – Whether to shuffle the deck after recycling

Return type:

None

class haive.games.core.game.containers.deck.StandardPlayingCardDeck¶

Bases: Deck

A standard 52-card playing card deck.

class Rank¶

Bases: str, enum.Enum

Standard card ranks.

Initialize self. See help(type(self)) for accurate signature.

class Suit¶

Bases: str, enum.Enum

Standard card suits.

Initialize self. See help(type(self)) for accurate signature.

classmethod create_standard_deck(include_jokers=False)¶

Create a standard 52-card deck.

Parameters:

include_jokers (bool) – Whether to include jokers in the deck

Returns:

A new StandardPlayingCardDeck instance

Return type:

StandardPlayingCardDeck