deck module

class deck.Deck(filename=None)[source]

Bases: object

Creates a uno Deck object. This reads in cards from a CSV file and stores them for use by the UnoGame object.

Parameters
  • filename (str) – Path to the file containing uno cards as strings

  • empty (bool) – Whether the deck is generated with or without cards

read_cards_from_file(filename)[source]

Reads cards from text file. Uses basic deck if execption encountered during read. Cards should be in the form COLOR,NUMBER,SPECIAL-TYPE (i.e red,1, or red,,draw-four)

Parameters

filename (str) – file to look for cards in

Returns

The list of cards created in the deck

Return type

list of Card

add_card(card)[source]

Adds a card to the deck

Parameters

card (Card) – card to add to the deck

shuffle_deck()[source]

Shuffles the deck of cards

get_top_card()[source]

Removes the top card from the deck

get_num_cards()[source]

Returns the number of cards left in the deck