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. | |
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.
|
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().