GameBase Class Reference

#include <gamebase.h>

Collaboration diagram for GameBase:

Collaboration graph
[legend]

List of all members.


Detailed Description

This is the base interface that all the card games must derive from. This class is used in connection with the RuleBase class. This class should contain the logical flow and enforce the rules of the game. If a method is not needed for a specific game, the method should throw a KardsGTError to prevent it's usage.

Author:
John Schneiderman

Public Member Functions

virtual void addOpponent (ComputerPlayer &opponent)
void addPlayer (Player &player)
 GameBase (UserProfileDatabase &profileDatabase)
virtual int handleGameStatus ()=0
virtual bool load (const QString &filename)=0
virtual int maximumPlayers () const =0
virtual int minimumPlayers () const =0
void resetGame (bool roundOver)
virtual bool save (const QString &filename)=0
virtual void startPlay ()=0
virtual ~GameBase ()

Protected Member Functions

virtual bool cardPlayed (const Card &card)=0
void clearPlayerHands ()
virtual void deal ()=0
void loadGameBase (QTextStream &in)
void nextDealer ()
void restorePlayerHands ()
void saveGameBase (QTextStream &out)
void savePlayerHands ()
virtual void setupNextPlayer ()=0

Protected Attributes

int m_dealerIndex
PlayerList m_players
CardSequence m_playSequence
UserProfileDatabasem_pProfileDatabase
int m_roundPoints

Constructor & Destructor Documentation

GameBase::GameBase ( UserProfileDatabase profileDatabase  ) 

Default constructor.

Parameters:
profileDatabase is the database of the user profiles.

GameBase::~GameBase (  )  [virtual]

Destructor.


Member Function Documentation

void GameBase::addOpponent ( ComputerPlayer opponent  )  [virtual]

Adds the opponent to play against the player.

Parameters:
opponent is the player to play against our local player.

void GameBase::addPlayer ( Player player  ) 

Adds the local player.

Parameters:
player is the local player.

virtual bool GameBase::cardPlayed ( const Card card  )  [protected, pure virtual]

This is the method to call when a card has been selected to play when implemented.

Parameters:
card is the card that the player has selected.
Returns:
true if the card was able to be played.

void GameBase::clearPlayerHands (  )  [protected]

Clears all the hands that were saved.

virtual void GameBase::deal (  )  [protected, pure virtual]

Deals the cards to the players when implemented.

virtual int GameBase::handleGameStatus (  )  [pure virtual]

This will handle the game status changes when implemented.

Returns:
a code to indicate the type of status change. All codes are game specific.

virtual bool GameBase::load ( const QString &  filename  )  [pure virtual]

This will load the game when implemented.

Parameters:
filename is the name of the file to load the game from.
Returns:
true if the game was successfully loaded, false elsewise.

void GameBase::loadGameBase ( QTextStream &  in  )  [protected]

This loads all the basic game values, in the manner as defined in the save method.

Parameters:
in is the source to read the game values from.

virtual int GameBase::maximumPlayers (  )  const [pure virtual]

This will give the maximum number of players allowed to play the game when implemented.

Note:
The actual value should come from a RuleBase call.
Returns:
the number of players allowed.

virtual int GameBase::minimumPlayers (  )  const [pure virtual]

This will give the minimum number of players needed to play the game when implemented.

Note:
The actual value should come from a RuleBase call.
Returns:
the number of players needed.

void GameBase::nextDealer (  )  [protected]

Sets the dealer index to the next dealer, and sets the current player in the player play list to be the player to left of the dealer.

Note:
Dealer is rotated in a clockwise motion.

void GameBase::resetGame ( bool  roundOver  ) 

Resets all values to be empty.

Parameters:
roundOver is true if the round is over, false elsewise.
Note:
When roundOver is true the player's round score is reset. See Player class for more information.

void GameBase::restorePlayerHands (  )  [protected]

Restores the players hands that were saved.

Note:
saveHands() needs to have been called before restore can be called.

virtual bool GameBase::save ( const QString &  filename  )  [pure virtual]

This will save the game when implemented.
The following format is expected:
label: value(s)
Each label-values should be on its own line.
The first label should be the name of the game, followed by each players information.
The last player in the player listings must be the human player.

Parameters:
filename is the name of the file to save the game to.
Returns:
true if the game was successfully saved, false elsewise.

void GameBase::saveGameBase ( QTextStream &  out  )  [protected]

This saves all the basic game values, in the manner as defined in the save method.

Parameters:
out is the source to save the game values to.

void GameBase::savePlayerHands (  )  [protected]

Saves all the players hands.

virtual void GameBase::setupNextPlayer (  )  [protected, pure virtual]

This sets up the turn for next player in the player's list when implemented.

virtual void GameBase::startPlay (  )  [pure virtual]

This method when implemented should begin all the necessary steps to start the game.


Member Data Documentation

int GameBase::m_dealerIndex [protected]

Parameters:
m_dealerIndex is the index in the player's list of the dealer.

Parameters:
m_players is all the players in the game.

Parameters:
m_playSequence is the current card play sequence in a round or phase.

Parameters:
m_pProfileDatabase is the pointer to the current profile database.

int GameBase::m_roundPoints [protected]

Parameters:
m_roundPoints is the total number of points in the round of play.


The documentation for this class was generated from the following files:

Generated on Tue Aug 12 23:24:01 2008 for KardsGT by  doxygen 1.5.5