Public Member Functions

Move< BoardCoord > Class Template Reference

Class to represent a move in the game. More...

#include <Game/Move.hpp>

List of all members.

Public Member Functions

 Move ()
 Default constructor producing an illegal move.
 Move (int color, const BoardCoord &start, const BoardCoord &dest)
 Basic Move constructor without additional parameters The constructor will check if the coordonates are valid. If not, the move will be considered as illegal.
 Move (int color, const BoardCoord &start, const BoardCoord &dest, const ParameterMap &parameters)
 Move constructor with additional parameters The constructor will check if the coordonates are valid. If not, the move will be considered as illegal.
void setProperty (const std::string &name, int value)
 Defines a new property.
the name of the property to check if the move have it

Determines if the move have the property names name

Returns:
true if the property named name does exists
bool hasProperty (const std::string &name) const
the name of the property to get

Returns the value associated to the property named name>/a>

Returns:
the value of the property
int getProperty (const std::string &name) const
bool isLegal () const
void invalidate ()
 Makes the move illegal.
int color () const
const BoardCoord & start () const
const BoardCoord & dest () const

Detailed Description

template<typename BoardCoord>
class Move< BoardCoord >

Class to represent a move in the game.

Basically, a move is characterised by a start position (the position where the piece to move is (start())) and a destination (the place where your piece will be (dest()))
Additionnaly to that, the colour completes this structure.
The colour (color()) could be removed, but, we would like to be sure that the player who generates the move, is the owner of the piece to move.
Since, we want to represent a move for "every" board system possible, the coords of the origin and destination are reprenseted in a generic way (depending on the board)
Technically, there is not way to know if a move is illegal from itself. So the default constructor Move() builds an illegal move. Secondly, all moves using invalid coords is also set to illegal. Moreover, a move this can be set to invalid with invalidate(). Finally and to be as generic as possible (e.g. in a dungeon & dragons game), you can add parameters to a move (e.g. bonuses) with setProperty. Such parameters does associate a value to a name. The existency can be checked using hasProperty and read with getProperty
The default constructor Move() create an empty illegal move.
The second constructor create a legal move without any parameters. The move is legal is the coords used for start and destination position are also legal.


Constructor & Destructor Documentation

template<typename BoardCoord>
Move< BoardCoord >::Move ( int  color,
const BoardCoord &  start,
const BoardCoord &  dest 
) [inline]

Basic Move constructor without additional parameters The constructor will check if the coordonates are valid. If not, the move will be considered as illegal.

Parameters:
color the color of the player moving
start the starting point of the move
dest the destination of the move
template<typename BoardCoord>
Move< BoardCoord >::Move ( int  color,
const BoardCoord &  start,
const BoardCoord &  dest,
const ParameterMap &  parameters 
) [inline]

Move constructor with additional parameters The constructor will check if the coordonates are valid. If not, the move will be considered as illegal.

Parameters:
color the color of the player moving
start the starting point of the move
dest the destination of the move
parameters the additional parameters associated to the move

Member Function Documentation

template<typename BoardCoord>
int Move< BoardCoord >::color (  )  const [inline]
Returns:
the color of the player initiating this move
template<typename BoardCoord>
const BoardCoord& Move< BoardCoord >::dest (  )  const [inline]
Returns:
the destination of the move
template<typename BoardCoord>
bool Move< BoardCoord >::isLegal (  )  const [inline]
Returns:
true if the move is legal
template<typename BoardCoord>
void Move< BoardCoord >::setProperty ( const std::string &  name,
int  value 
) [inline]

Defines a new property.

Parameters:
name the name to call the property
value the value of the property to keep
template<typename BoardCoord>
const BoardCoord& Move< BoardCoord >::start (  )  const [inline]
Returns:
the start of the move

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