Cute Chess  0.1
Public Member Functions | Static Public Attributes | List of all members
Chess::Piece Class Reference

A chess piece. More...

#include <piece.h>

Public Member Functions

bool isEmpty () const
 
bool isValid () const
 
bool isWall () const
 
bool operator!= (const Piece &other) const
 
bool operator< (const Piece &other) const
 
bool operator== (const Piece &other) const
 
bool operator> (const Piece &other) const
 
 Piece (int type=NoPiece)
 
 Piece (Side side, int type)
 
void setSide (Side side)
 
void setType (int type)
 
Side side () const
 
int type () const
 

Static Public Attributes

static const int NoPiece = 0
 
static const int WallPiece = 100
 

Detailed Description

A chess piece.

The Piece class represents the contents of a square on the chessboard. It can be an empty piece (NoPiece) or a wall piece (WallPiece) belonging to neither player (NoSide), or it can be any chess piece belonging to either White or Black.

For performance reasons the class is just a wrapper for integer, and it has a constructor for implicitly converting integers to Piece objects.

Note
A Board object is needed to convert between a Piece and a string.

Constructor & Destructor Documentation

Chess::Piece::Piece ( int  type = NoPiece)
inline

Creates a new piece of type type for NoSide.

Chess::Piece::Piece ( Side  side,
int  type 
)
inline

Creates a new piece of type type for side.

Member Function Documentation

bool Chess::Piece::isEmpty ( ) const
inline

Returns true if the piece is empty (type is NoPiece).

bool Chess::Piece::isValid ( ) const
inline

Returns true if this is a valid chess piece.

bool Chess::Piece::isWall ( ) const
inline

Returns true if this is a wall piece (inaccessible square).

bool Chess::Piece::operator!= ( const Piece other) const
inline

Returns true if other is different from this piece.

bool Chess::Piece::operator< ( const Piece other) const
inline

Returns true if this piece is less than other.

bool Chess::Piece::operator== ( const Piece other) const
inline

Returns true if other is the same as this piece.

bool Chess::Piece::operator> ( const Piece other) const
inline

Returns true if this piece is more than other.

void Chess::Piece::setSide ( Side  side)
inline

Sets the side to side.

void Chess::Piece::setType ( int  type)
inline

Sets the type to type.

Side Chess::Piece::side ( ) const
inline

Returns the side the piece belongs to.

int Chess::Piece::type ( ) const
inline

Returns the type of the piece.

Member Data Documentation

const int Chess::Piece::NoPiece = 0
static

No piece. Used for empty squares.

const int Chess::Piece::WallPiece = 100
static

A wall square outside of board.


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