EngineTwo Class Reference

The game engine for two players. More...

#include <engine_two.h>

Inheritance diagram for EngineTwo:

Inheritance graph
[legend]
Collaboration diagram for EngineTwo:

Collaboration graph
[legend]
List of all members.

Public Types

enum  MoveState { FirstPlayerTurn = 0, SecondPlayerTurn = 1 }
 Move phase states. More...

Public Slots

virtual void playerInput (int inputId, int playerNumber, int cardNumber)
 Player input available.
bool isLegalMove (int card1, int card2, int playerNumber)
 Check whether the two cards played are legal, supposed the given player is the second one.
int whoWonMove (int card1, int card2)
 Check who won a move, the first or the second card.

Public Member Functions

 EngineTwo (QWidget *parent, Deck *deck, DisplayTwo *display)
 Constructor for the game engine.
virtual void startGame (Suite trump, int startPlayer)
 Start a new game.
virtual void stopGame ()
 Stop a game.
MoveState currentMovePhase ()
 Retrieve the current move phase.
int playedCard (int no)
 Retrieve the currently played card.

Protected Slots

void gameLoopStart ()
 First part of the game loop.
void gameLoopFinish ()
 Second part of the game loop.

Protected Member Functions

void activatePlayer (int playerNumber)
 Active the current player to the given player number.
bool gameOver ()
 Check whether the game is over.
int evaluateGame ()
 Called after game ends and then give points to players.

Detailed Description

The game engine for two players.

Definition at line 42 of file engine_two.h.


Member Enumeration Documentation

enum EngineTwo::MoveState
 

Move phase states.

Enumerator:
FirstPlayerTurn 
SecondPlayerTurn 

Definition at line 48 of file engine_two.h.


Constructor & Destructor Documentation

EngineTwo::EngineTwo QWidget *  parent,
Deck deck,
DisplayTwo display
 

Constructor for the game engine.

Parameters:
parent The parent window
deck The card deck
display The display engine

Definition at line 37 of file engine_two.cpp.

References AbstractEngine::mCurrentPlayer.


Member Function Documentation

void EngineTwo::activatePlayer int  playerNumber  )  [protected]
 

Active the current player to the given player number.

Enable inputs etc.

Parameters:
playerNumber The new player playerNumber

Definition at line 374 of file engine_two.cpp.

References AbstractEngine::mPlayers.

Referenced by gameLoopStart().

MoveState EngineTwo::currentMovePhase  )  [inline]
 

Retrieve the current move phase.

Returns:
The move phase.

Definition at line 73 of file engine_two.h.

int EngineTwo::evaluateGame  )  [protected]
 

Called after game ends and then give points to players.

Returns:
The winning player

Definition at line 229 of file engine_two.cpp.

References Player::addGame(), Player::addScore(), Player::addWonGame(), AbstractEngine::mPlayers, Player::name(), Player::points(), DisplayTwo::showScore(), and DisplayTwo::showText().

Referenced by gameLoopFinish().

Here is the call graph for this function:

void EngineTwo::gameLoopFinish  )  [protected, slot]
 

Second part of the game loop.

Definition at line 149 of file engine_two.cpp.

References Player::addWonCard(), evaluateGame(), FirstPlayerTurn, gameLoopStart(), gameOver(), global_debug, Player::increaseMovesWon(), AbstractEngine::isGameRunning(), AbstractEngine::mCurrentPlayer, AbstractEngine::mGameStatus, AbstractEngine::mPlayers, Player::noOfMovesWon(), AbstractEngine::player(), Player::points(), DisplayTwo::remove(), SecondPlayerTurn, DisplayTwo::showMove(), AbstractEngine::signalGameOver(), AbstractEngine::Stopped, and whoWonMove().

Referenced by playerInput().

void EngineTwo::gameLoopStart  )  [protected, slot]
 

First part of the game loop.

Definition at line 47 of file engine_two.cpp.

References activatePlayer(), AbstractEngine::isGameRunning(), and AbstractEngine::mCurrentPlayer.

Referenced by gameLoopFinish().

bool EngineTwo::gameOver  )  [protected]
 

Check whether the game is over.

Returns:
True if the game is over, false otherwise

Definition at line 219 of file engine_two.cpp.

References global_debug.

Referenced by gameLoopFinish().

bool EngineTwo::isLegalMove int  card1,
int  card2,
int  playerNumber
[slot]
 

Check whether the two cards played are legal, supposed the given player is the second one.

Parameters:
card1 The card played by the first player
card2 The card played by the second player
playerNumber The id of the latter player (to access its cards)
Returns:
true if the move is legal, false otherwise.

Definition at line 395 of file engine_two.cpp.

References Player::getCard(), Deck::getCardType(), Deck::getSuite(), CardDeck::Jack, and AbstractEngine::player().

Referenced by playerInput().

int EngineTwo::playedCard int  no  )  [inline]
 

Retrieve the currently played card.

Parameters:
no Which card (0,1)
Returns:
The played card.

Definition at line 79 of file engine_two.h.

void EngineTwo::playerInput int  inputId,
int  playerNumber,
int  cardNumber
[virtual, slot]
 

Player input available.

Parameters:
inputId The input device id
playerNumber The player number [0-1]
cardNumber The card number [0-7]

Implements AbstractEngine.

Definition at line 58 of file engine_two.cpp.

References Player::deleteCard(), FirstPlayerTurn, gameLoopFinish(), Player::getCard(), Deck::getCardType(), Deck::getSuite(), global_debug, isLegalMove(), AbstractEngine::mCurrentPlayer, AbstractEngine::mPlayers, Deck::name(), DisplayTwo::play(), AbstractEngine::player(), SecondPlayerTurn, Player::stopTurn(), TIME_END_MOVE, and DisplayTwo::turn().

void EngineTwo::startGame Suite  trump,
int  startPlayer
[virtual]
 

Start a new game.

Parameters:
trump The trump suite.
startPlayer The start player

Implements AbstractEngine.

Definition at line 319 of file engine_two.cpp.

References Player::addGame(), DisplayTwo::deal(), FirstPlayerTurn, AbstractEngine::mCurrentPlayer, AbstractEngine::mGameStatus, AbstractEngine::mPlayers, AbstractEngine::player(), and AbstractEngine::Running.

Here is the call graph for this function:

void EngineTwo::stopGame  )  [virtual]
 

Stop a game.

Implements AbstractEngine.

Definition at line 350 of file engine_two.cpp.

References AbstractEngine::mPlayers.

int EngineTwo::whoWonMove int  card1,
int  card2
[slot]
 

Check who won a move, the first or the second card.

Parameters:
card1 Card value played by first mover
card2 Card value played by latter mover

Definition at line 450 of file engine_two.cpp.

References CardDeck::Ace, Deck::getCardType(), Deck::getSuite(), global_debug, CardDeck::Jack, and CardDeck::Ten.

Referenced by gameLoopFinish().


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