cardgames.components.deck.Deck
- class cardgames.components.deck.Deck
Bases:
objectSimulate a deck of cards through
Deck.all_cards. Methods simulate some common actions like shuffling and dealing cards.- __init__()
Methods
__init__()deal(ncards, destinations, location)Takes cards from the top of deck, and deals to either the top or bottom of the deck/s listed in destinations
empty()Clears all cards from
Deck.all_cardsto create an empty deck, for example when the deck is that of acardgames.components.player.Playerwho hasn't yet been delt cards.order()Reorders the deck (ascending).
shuffle()Randomly reorders
Deck.all_cardsattribute.upturn(ncards)Turns over ncards number of cards to reveal the value and suit.
Attributes
List of tuples: each tuple represents one card (value, suit) currently in the deck.
- all_cards
List of tuples: each tuple represents one card (value, suit) currently in the deck.
- Return type
list(tuple)
- deal(ncards, destinations, location)
Takes cards from the top of deck, and deals to either the top or bottom of the deck/s listed in destinations
- Parameters
ncards (int) – number of cards to deal
destinations (list) – list of
deck.Deck.all_cardsdecks for the cards to be delt to.location (str) – Specifies to deal to the “Top” or “Bottom” of the destination decks
- empty()
Clears all cards from
Deck.all_cardsto create an empty deck, for example when the deck is that of acardgames.components.player.Playerwho hasn’t yet been delt cards.
- order()
Reorders the deck (ascending). Suit order is random. (Mostly for testing purposes)
- shuffle()
Randomly reorders
Deck.all_cardsattribute.
- upturn(ncards)
Turns over ncards number of cards to reveal the value and suit.
- Parameters
ncards (int) – The number of cards to turn over and display.