tartan  1.2.1.0
tt::chess::King Class Reference

King chess Piece. More...

#include <chess.hpp>

Inheritance diagram for tt::chess::King:
[legend]
Collaboration diagram for tt::chess::King:
[legend]

Classes

class  Turn
 King Turn. More...
 

Public Member Functions

virtual TurnMap moveMap (int mode=0) const override
 Generic moves. More...
 
bool check () const
 Check if a King is under check. More...
 
bool checkmate () const
 Check if a King is under checkmate. More...
 
bool castled () const
 Has the King object already performed the castling Turn. More...
 
 Piece (const Position &pos={1, 1}, Color col=Color::White)
 Construct new Piece. More...
 
- Public Member Functions inherited from tt::Piece
Color color () const
 Piece color. More...
 
Color setColor (Color col)
 Set the color. More...
 
const Positionposition () const
 Piece Position. More...
 
Positionposition ()
 Piece Position. More...
 
Position setPosition (const Position &)
 Set Piece position. More...
 
virtual Position move (const Position &to)
 Move piece. More...
 
const Boardboard () const
 Piece board. More...
 
Boardboard ()
 Piece board. More...
 
BoardsetBoard (Board *b)
 Set Piece Board. More...
 
std::size_t movesMade () const
 Moves count. More...
 
std::size_t turnIndex () const
 Current turn index. More...
 
 Piece (const Position &pos={1, 1}, Color col=Color::White)
 Construct new Piece. More...
 

Additional Inherited Members

- Public Types inherited from tt::Piece
enum class  Color { Black = 0 , White = 1 }
 Piece color. More...
 
- Static Public Member Functions inherited from tt::Piece
static TurnMap diagonalMoves (const Piece *p)
 Construct diagonal moves TurnMap. More...
 
static TurnMap straightMoves (const Piece *p)
 Construct straight moves (up, down, left, right) TurnMap. More...
 
- Protected Attributes inherited from tt::Piece
Color p_color
 Piece color. More...
 
Position p_position
 Piece Position. More...
 
Boardp_board = nullptr
 Piece Board. More...
 
std::size_t p_movesMade = 0
 Turns count Count of turns Piece have made.
 
std::size_t p_turnIndex = 0
 Last turn index. More...
 

Detailed Description

King chess Piece.

Member Function Documentation

◆ castled()

bool tt::chess::King::castled ( ) const
inline

Has the King object already performed the castling Turn.

Returns
true if King object have done castling already, false otherwise

◆ check()

bool tt::chess::King::check ( ) const

Check if a King is under check.

Returns
true if King object is under check, false otherwise

◆ checkmate()

bool tt::chess::King::checkmate ( ) const

Check if a King is under checkmate.

Returns
true if King object is under checkmate, false otherwise

◆ moveMap()

TurnMap tt::chess::King::moveMap ( int  mode = 0) const
overridevirtual

Generic moves.

Note
Developer had and intention that You will define unscoped enumeration for mode in Your Board class. It's value will be passe to function and influence it's behaivor in some way.
Parameters
modeoptional mode constant to influence the moveMap() behaivor in child classes.
Returns
TurnMap object filled with Turn objects. May not contain turns that are not possible because of piece placement

Implements tt::Piece.

◆ Piece()

tt::Piece::Piece

Construct new Piece.

Parameters
posPiece Position
colPiece Color
See also
color(), position()

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