tartan  1.2.1.0
tt::chess::King::Turn Class Reference

King Turn. More...

#include <chess.hpp>

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

Public Member Functions

 Turn (const Piece *f, const Position &t, const Piece *c=nullptr, Rook::Turn *castling=nullptr, bool p=true)
 Make new King Turn object. More...
 
bool isEqual (const Piece::Turn &) const override
 Compare turns. More...
 
virtual void apply (int mode=0) override
 Apply turn. More...
 
virtual void undo () override
 Undo turn. More...
 
virtual std::string str () const override
 String Turn representation. More...
 
- Public Member Functions inherited from tt::Piece::Turn
 Turn (const Piece *tpiece, const Position &to, const Piece *cap=nullptr, bool possible=true)
 Construct new Turn object. More...
 
Position to () const
 Position where piece will end up after turn. More...
 
Position from () const
 Position the turn is started at. More...
 
const Piecepiece () const
 Turn Piece. More...
 
Piecepiece ()
 Turn Piece. More...
 
const Piececapture () const
 Captured piece. More...
 
Piececapture ()
 Captured piece. More...
 
bool possible () const
 Turn viability. More...
 
bool setPossible (bool c)
 Set the turn viability. More...
 
virtual auto clone () const -> std::decay< decltype(*this)>::type *
 Clone current Turn. More...
 

Additional Inherited Members

- Protected Attributes inherited from tt::Piece::Turn
Position t_from
 Turn piece starting position
 
Position t_to
 Turn piece finishing position
 
Piecet_piece
 Turn Piece inself
 
Piecet_capture
 Piece that is captured as the resul of turn.
 
bool t_possible
 Turn viability.
 

Detailed Description

King Turn.

Accomodates the Piece::Turn for castling turns

Constructor & Destructor Documentation

◆ Turn()

tt::chess::King::Turn::Turn ( const Piece f,
const Position t,
const Piece c = nullptr,
Rook::Turn castling = nullptr,
bool  p = true 
)
inline

Make new King Turn object.

Parameters
fKing pointer that performs the move
ttarget Turn Position
ccaptured Piece
castlingRook object pointer which will perform castling move with f
pTurn::t_possibe value

Member Function Documentation

◆ apply()

virtual void tt::chess::King::Turn::apply ( int  mode = 0)
overridevirtual

Apply turn.

Applies current turn. Should be reimplemented in child Piece class if it have to do something special on move.

This does the next:

You can define unscoped enum and use it with this fucntion to perform different applying logic on demand.

Parameters
modeoptional apply mode parameter

Reimplemented from tt::Piece::Turn.

◆ isEqual()

bool tt::chess::King::Turn::isEqual ( const Piece::Turn rhs) const
overridevirtual

Compare turns.

Should be reimplemented in child Piece class if it's Turn logic differs.

Parameters
rhsTurn object compare to
Returns
true if rhs turn is the same as current object

Reimplemented from tt::Piece::Turn.

◆ str()

virtual std::string tt::chess::King::Turn::str ( ) const
overridevirtual

String Turn representation.

This function may be redefined in Piece::Turn that inherit from Piece depending on new piece implementation

Returns
string representation of current Turn object

Reimplemented from tt::Piece::Turn.

◆ undo()

virtual void tt::chess::King::Turn::undo ( )
overridevirtual

Undo turn.

Opposite to apply(). Should be reimplemented in child Piece class if it's apply() function does something special on applying.

Reimplemented from tt::Piece::Turn.


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