Public Member Functions

Piece Class Reference

Represents a piece in the game. More...

#include <Game/Piece.hpp>

List of all members.

Public Member Functions

 Piece ()
 Default constructor creating an invalid piece.
 Piece (int owner, int type)
 Constructor building a piece of type type for the owner owner
bool isValid () const
void setProperty (const std::string &name, int value)
 Sets a new property named name and assigned to the value
bool hasProperty (const std::string &name) const
 Checks if the named property name is available for this piece.
int getProperty (const std::string &name) const
 Gets the value associated with the property named name
int color () const
int type () const

Detailed Description

Represents a piece in the game.

The Piece does only contain the type (type()) and the color (color()) of the owner. Moreover, to be more generic, additionnal information can be added using property (a value associated to a name). Easy to use function are provided to interact with the properties : setProperty() hasProperty() and getProperty(). The piece can also be invalid, for example it is not a piece (no piece present on the board at this piece)


Constructor & Destructor Documentation

Piece::Piece ( int  owner,
int  type 
)

Constructor building a piece of type type for the owner owner

Parameters:
owner the color of the owner of the piece
type the type of the piece to create

Member Function Documentation

int Piece::color (  )  const [inline]
Returns:
Gets the color of the piece
int Piece::getProperty ( const std::string &  name  )  const

Gets the value associated with the property named name

Parameters:
name the name of the property for which the value is returned
bool Piece::hasProperty ( const std::string &  name  )  const

Checks if the named property name is available for this piece.

Parameters:
name the name of the property to check
bool Piece::isValid (  )  const [inline]
Returns:
true if the piece is valid (is false when it is not a piece)
void Piece::setProperty ( const std::string &  name,
int  value 
)

Sets a new property named name and assigned to the value

Parameters:
name the name of the new property
value the value associated to the property
int Piece::type (  )  const [inline]
Returns:
Gets the type of the piece

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