Deck Class Reference

The deck stores a card deck, handles random functions like shuffling and deals the cards. More...

#include <deck.h>

List of all members.

Public Member Functions

 Deck (long seed, QObject *parent)
 Constructor for the deck.
virtual ~Deck ()
 Destructor.
int cardNumber ()
 Retrieve number of cards in this deck.
void shuffle ()
 Shuffle the cards and reset the pile.
Suite randomTrump ()
 Draw a random trump from all cards.
int drawCard ()
 Draw a random card out of the pile of existing ones.

Static Public Member Functions

static Suite getSuite (int card)
 Get the suite (Club, .
static CardType getCardType (int card)
 Get the card type (ace, king, .
static int getCardValue (int card)
 Get the value in points of the given card (number).
static QString name (Suite suite, CardType type)
 Returns a verbose name for a card.
static QString name (int card)
 Returns a verbose name for a card.


Detailed Description

The deck stores a card deck, handles random functions like shuffling and deals the cards.

Definition at line 50 of file deck.h.


Constructor & Destructor Documentation

Deck::Deck long  seed,
QObject *  parent
 

Constructor for the deck.

Parameters:
seed The random seed
parent The parent object

Definition at line 38 of file deck.cpp.

References shuffle().

Here is the call graph for this function:

Deck::~Deck  )  [virtual]
 

Destructor.

Definition at line 47 of file deck.cpp.


Member Function Documentation

int Deck::cardNumber  ) 
 

Retrieve number of cards in this deck.

Returns:
Number of cards.

Definition at line 52 of file deck.cpp.

Referenced by AbstractDisplay::createCardSprites().

int Deck::drawCard  ) 
 

Draw a random card out of the pile of existing ones.

Returns:
A random card

Definition at line 91 of file deck.cpp.

Referenced by Player::deal().

CardType Deck::getCardType int  card  )  [static]
 

Get the card type (ace, king, .

..) of a given card (number)

Parameters:
card The card number
Returns:
The card type (ace, king, ...).

Definition at line 110 of file deck.cpp.

Referenced by getCardValue(), EngineTwo::isLegalMove(), name(), EngineTwo::playerInput(), randomTrump(), and EngineTwo::whoWonMove().

int Deck::getCardValue int  card  )  [static]
 

Get the value in points of the given card (number).

Parameters:
card The card number
Returns:
The card value [0, 2, 3, 4, 10, 11].

Definition at line 117 of file deck.cpp.

References CardDeck::Ace, getCardType(), CardDeck::Jack, CardDeck::King, CardDeck::Queen, and CardDeck::Ten.

Referenced by Player::addWonCard().

Here is the call graph for this function:

Suite Deck::getSuite int  card  )  [static]
 

Get the suite (Club, .

..) of a given card (number)

Parameters:
card The card number
Returns:
The suite.

Definition at line 103 of file deck.cpp.

Referenced by EngineTwo::isLegalMove(), name(), EngineTwo::playerInput(), randomTrump(), and EngineTwo::whoWonMove().

QString Deck::name int  card  )  [static]
 

Returns a verbose name for a card.

Parameters:
card The card as integer
Returns:
A descriptive string.

Definition at line 130 of file deck.cpp.

References getCardType(), getSuite(), and name().

Here is the call graph for this function:

QString Deck::name Suite  suite,
CardType  type
[static]
 

Returns a verbose name for a card.

Parameters:
suite The card suite
type The card type
Returns:
A descriptive string.

Definition at line 138 of file deck.cpp.

References CardDeck::Ace, CardDeck::Club, CardDeck::Diamond, CardDeck::Eight, CardDeck::Grand, CardDeck::Heart, CardDeck::Jack, CardDeck::King, CardDeck::Nine, CardDeck::Queen, CardDeck::Seven, CardDeck::Spade, and CardDeck::Ten.

Referenced by name(), and EngineTwo::playerInput().

Suite Deck::randomTrump  ) 
 

Draw a random trump from all cards.

This is done by drawing a random card and choosing its suite as trump. In case a Jack is drawn a Grand is made trump.

Returns:
A random trump.

Definition at line 59 of file deck.cpp.

References getCardType(), getSuite(), CardDeck::Grand, CardDeck::Jack, and NUMBER_OF_CARDS.

Referenced by Mainwindow::startGame().

Here is the call graph for this function:

void Deck::shuffle  ) 
 

Shuffle the cards and reset the pile.

Definition at line 71 of file deck.cpp.

References NUMBER_OF_CARDS.

Referenced by Deck(), and Mainwindow::startGame().


The documentation for this class was generated from the following files:
Generated on Tue May 1 09:34:40 2007 for LSkat by  doxygen 1.4.6