Public Member Functions

Game< GameBoard, GameRules > Class Template Reference

A game is just observers / controlers. More...

#include <Game/Game.hpp>

Inheritance diagram for Game< GameBoard, GameRules >:
AbstractGame

List of all members.

Public Member Functions

 ~Game ()
const GameBoard * getBoard ()
const GameRules * getRules ()
bool addControler (Controler< GameBoard > *pControler)
bool addStatusListener (Listener< Move< Coords > > *pListener)
bool checkMove ()
bool play ()
int getCurrentColorTurn () const
int getVictoriousColor () const
bool isVictory () const
bool isDraw () const
bool loadHistory (const std::string &fileName)
bool saveHistory (const std::string &fileName)

Detailed Description

template<typename GameBoard, typename GameRules>
class Game< GameBoard, GameRules >

A game is just observers / controlers.

Controlers are seen like players. They propose moves and the rules checks the correctness of these. If it is the board will apply the move. You can have observers (generally UI) to look at the game. These just knows the move accepted. The game will just play by rotating players (controlers to who we are asking for moves) and accepting the moves. The game will stop when a victory or a draw is reached


Constructor & Destructor Documentation

template<typename GameBoard , typename GameRules >
Game< GameBoard, GameRules >::~Game (  )  [inline]

The controlers are destructed


Member Function Documentation

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::addControler ( Controler< GameBoard > *  pControler  )  [inline]

Adds a controler to give moves (aka: player)

Parameters:
pControler 
Returns:
false if enough controlers are in the game
template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::addStatusListener ( Listener< Move< Coords > > *  pListener  )  [inline]

Adds a listener for moves (aka: UI)

Parameters:
pListener 
Returns:
always true
template<typename GameBoard , typename GameRules >
const GameBoard* Game< GameBoard, GameRules >::getBoard (  )  [inline]

Gets the board

Returns:
template<typename GameBoard , typename GameRules >
int Game< GameBoard, GameRules >::getCurrentColorTurn (  )  const [inline]

Return the color to which player to play

Returns:
template<typename GameBoard , typename GameRules >
const GameRules* Game< GameBoard, GameRules >::getRules (  )  [inline]

Gets the rules

Returns:
template<typename GameBoard , typename GameRules >
int Game< GameBoard, GameRules >::getVictoriousColor (  )  const [inline, virtual]

Gets the color of the winning player

Returns:

Implements AbstractGame.

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::isDraw (  )  const [inline, virtual]

Gets if the game finished in a draw

Returns:

Implements AbstractGame.

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::isVictory (  )  const [inline, virtual]

Gets if the game finished in a victory

Returns:

Implements AbstractGame.

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::loadHistory ( const std::string &  fileName  )  [inline, virtual]

Loads an history from a file named fileName

Parameters:
fileName 
Returns:
false if it was not possible to load the file

Implements AbstractGame.

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::play (  )  [inline, virtual]

Plays the game until the rules declare that there is one player victorious or a draw is trigerred

Implements AbstractGame.

template<typename GameBoard , typename GameRules >
bool Game< GameBoard, GameRules >::saveHistory ( const std::string &  fileName  )  [inline, virtual]

Saves the game history in a file fileName

Parameters:
fileName 
Returns:
false if it was not possible to save the file

Implements AbstractGame.


The documentation for this class was generated from the following file:
 All Classes Functions Variables