Generic Piece Turn on Board.
More...
#include <board.hpp>
|
Position | t_from |
| Turn piece starting position
|
|
Position | t_to |
| Turn piece finishing position
|
|
Piece * | t_piece |
| Turn Piece inself
|
|
Piece * | t_capture |
| Piece that is captured as the resul of turn.
|
|
bool | t_possible |
| Turn viability.
|
|
Generic Piece Turn on Board.
Class should be defined as derived from Piece::Turn in every class derived from Piece.
◆ Turn()
tt::Turn::Turn |
( |
const Piece * |
tpiece, |
|
|
const Position & |
to, |
|
|
const Piece * |
cap = nullptr , |
|
|
bool |
possible = true |
|
) |
| |
Construct new Turn object.
- Parameters
-
tpiece | pointer to Piece that performs turn |
to | Location where of tpiece after the turn is applied |
cap | captured Piece. Should be provided if turn captures some pieces |
possible | true , if turn is marked as possible, false otherwise |
◆ apply()
void tt::chess::Turn::apply |
( |
int |
mode = 0 | ) |
|
|
virtual |
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
-
mode | optional apply mode parameter |
Reimplemented in tt::chess::Pawn::Turn, and tt::chess::King::Turn.
◆ capture() [1/2]
Piece * tt::Piece::Turn::capture |
( |
| ) |
|
|
inline |
Captured piece.
- Returns
- piece that turn will be captured when turn is applied
◆ capture() [2/2]
const Piece * tt::Piece::Turn::capture |
( |
| ) |
const |
|
inline |
Captured piece.
- Returns
- piece that turn will be captured when turn is applied
◆ clone()
auto tt::Turn::clone |
( |
| ) |
const -> std::decay<decltype(*this)>::type* |
|
virtual |
Clone current Turn.
- Returns
- pointer to new memory with Turn object indentical to invoking object
◆ from()
Position tt::Piece::Turn::from |
( |
| ) |
const |
|
inline |
Position the turn is started at.
- Returns
- target turn position
◆ isEqual()
bool tt::chess::Turn::isEqual |
( |
const Turn & |
rhs | ) |
const |
|
virtual |
◆ piece() [1/2]
Piece * tt::Piece::Turn::piece |
( |
| ) |
|
|
inline |
Turn Piece.
- Returns
- piece whose turn current object describes
◆ piece() [2/2]
const Piece * tt::Piece::Turn::piece |
( |
| ) |
const |
|
inline |
Turn Piece.
- Returns
- piece whose turn current object describes
◆ possible()
bool tt::Piece::Turn::possible |
( |
| ) |
const |
|
inline |
Turn viability.
- Returns
true
, if turn is possible, false otherwise
◆ setPossible()
bool tt::Piece::Turn::setPossible |
( |
bool |
c | ) |
|
|
inline |
Set the turn viability.
- Parameters
-
- Returns
- old viability value
◆ str()
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 in tt::chess::King::Turn.
◆ to()
Position where piece will end up after turn.
- Returns
- starting turn position
◆ undo()
void tt::chess::Turn::undo |
( |
| ) |
|
|
virtual |
◆ operator!=
bool operator!= |
( |
const Turn & |
lhs, |
|
|
const Turn & |
rhs |
|
) |
| |
|
friend |
Inverted comparison operator.
- Parameters
-
lhs | left object of == operator |
rhs | right object of == operator |
- Returns
- the value of !lhs.isEqual(rhs)
- See also
- isEqual()
◆ operator<<
◆ operator==
bool operator== |
( |
const Turn & |
lhs, |
|
|
const Turn & |
rhs |
|
) |
| |
|
friend |
Comparison operator.
- Parameters
-
lhs | left object of == operator |
rhs | right object of == operator |
- Returns
- the value of lhs.isEqual(rhs)
- See also
- isEqual()
The documentation for this class was generated from the following files:
- board/include/tartan/board/board.hpp
- board/turn.cpp
- chess/pieces/bishop/bishopTurn.cpp
- chess/pieces/king/kingTurn.cpp
- chess/pieces/knight/knightTurn.cpp
- chess/pieces/pawn/pawnTurn.cpp
- chess/pieces/queen/queenTurn.cpp
- chess/pieces/rook/rookTurn.cpp