Protected Attributes | Friends | List of all members
cwchess::Piece Class Reference

A particular piece on the board. More...

#include <Piece.h>

Public Member Functions

Constructors
 Piece (void)
 Construct an empty piece (nothing).
 
 Piece (Color const& color, Type const& type, Flags const& flags)
 Construct a fully initialized Piece. More...
 
 Piece (Color const& color, Type const& type)
 Construct a fully initialized Piece with all Flags reset. More...
 
 Piece (Code const& code, Flags const& flags)
 Construct a fully initialized Piece. More...
 
 Piece (Piece const& piece)
 Copy-constructor.
 
Assignment operators
Piece&  operator= (Piece const& piece)
 Assign from another Piece.
 
Piece&  operator= (Color const& color)
 Just change the color.
 
Piece&  operator= (Type const& type)
 Just change the type.
 
Piece&  operator= (Code const& code)
 Just change the code.
 
Piece&  operator= (Flags const& flags)
 Just change the flags.
 
Accessors
Color color (void) const
 Return the color of the piece. More...
 
Type type (void) const
 The type of this piece.
 
Flags flags (void) const
 The flags of this piece.
 
Code code (void) const
 The code of this piece.
 

Protected Attributes

Code M_code
 The Code of this piece.
 
Flags M_flags
 Flags for this piece.
 

Friends

class ChessPosition
 
Comparison operators
bool operator== (Piece const& piece1, Piece const& piece2)
 Return TRUE if the Code of the pieces are equal. More...
 
bool operator!= (Piece const& piece1, Piece const& piece2)
 Return TRUE if the Code of the pieces are unequal. More...
 
bool operator== (Piece const& piece, Type const& type)
 Return TRUE if piece is a type.
 
bool operator== (Type const& type, Piece const& piece)
 Return TRUE if piece is a type.
 
bool operator!= (Piece const& piece, Type const& type)
 Return TRUE if piece is not a type.
 
bool operator!= (Type const& type, Piece const& piece)
 Return TRUE if piece is not a type.
 
bool operator== (Piece const& piece, Color const& color)
 Return TRUE if piece has color color.
 
bool operator== (Color const& color, Piece const& piece)
 Return TRUE if piece has color color.
 
bool operator!= (Piece const& piece, Color const& color)
 Return TRUE if piece does not have color color.
 
bool operator!= (Color const& color, Piece const& piece)
 Return TRUE if piece does not have color color.
 
bool operator== (Piece const& piece, Code const& code)
 Return TRUE if piece has code code.
 
bool operator== (Code const& code, Piece const& piece)
 Return TRUE if piece has code code.
 
bool operator!= (Piece const& piece, Code const& code)
 Return TRUE if piece does not have code code.
 
bool operator!= (Code const& code, Piece const& piece)
 Return TRUE if piece does not have code code.
 

Detailed Description

A particular piece on the board.

This class represents pieces on the chessboard (in the broadest sense of 'piece', including pawn, queen, king and even nothing).

Since the flags are hidden and not of the users concern, you can consider a Piece to be equivalent with Code.

See also
ChessPosition::piece_at

Definition at line 45 of file Piece.h.

Constructor & Destructor Documentation

cwchess::Piece::Piece ( Color const&   color,
Type const&   type,
Flags const&   flags 
)
inline

Construct a fully initialized Piece.

Parameters
color: The color of the piece.
type: The type of the piece.
flags: All flags.

Definition at line 64 of file Piece.h.

cwchess::Piece::Piece ( Color const&   color,
Type const&   type 
)
inline

Construct a fully initialized Piece with all Flags reset.

Parameters
color: The color of the piece.
type: The type of the piece.

Definition at line 71 of file Piece.h.

cwchess::Piece::Piece ( Code const&   code,
Flags const&   flags 
)
inline

Construct a fully initialized Piece.

Parameters
code: The chess piece Code.
flags: All flags.

Definition at line 78 of file Piece.h.

Member Function Documentation

Color cwchess::Piece::color ( void  ) const
inline

Return the color of the piece.

Only valid if the type is not 'nothing'.

Definition at line 112 of file Piece.h.

References cwchess::Code::color().

Referenced by cwchess::ChessPosition::legal(), cwmm::ChessPositionWidget::load_FEN(), operator=(), cwchess::ChessPosition::reachables(), and cwchess::ChessPosition::swap_colors().

Friends And Related Function Documentation

bool operator!= ( Piece const&   piece1,
Piece const&   piece2 
)
friend

Return TRUE if the Code of the pieces are unequal.

This operator ignores the flags.

Definition at line 178 of file Piece.h.

bool operator== ( Piece const&   piece1,
Piece const&   piece2 
)
friend

Return TRUE if the Code of the pieces are equal.

This operator ignores the flags.

Definition at line 172 of file Piece.h.


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

Copyright © 2006 - 2010 Carlo Wood.  All rights reserved.