1#ifndef _TARTAN_CHESS_HPP_
2#define _TARTAN_CHESS_HPP_
4#include <tartan/board.hpp>
105 virtual void clear()
override;
309 virtual void apply(
int mode = 0)
override;
423 const Piece* c =
nullptr,
427 k_castlingTurn = castling;
431 virtual void apply(
int mode = 0)
override;
434 virtual ~Turn()
override {
435 delete k_castlingTurn;
463 bool calculateCheck()
const;
464 bool calculateCheckmate()
const;
465 bool k_castled =
false;
466 mutable bool k_check =
false;
467 mutable bool k_checkmate =
false;
8x8 game board
Definition board.hpp:690
Board()
Construct empty Board object.
Definition board.cpp:16
std::list< Piece * > PieceSetT
Type for representing set of pointers to Piece objects.
Definition board.hpp:700
virtual Piece::TurnMap possibleMoves(const Piece *p) const
Possible moves of a Piece by it's adress.
Definition board.cpp:71
Piece position at the Board.
Definition board.hpp:36
List of Turn objects.
Definition board.hpp:489
Generic Piece Turn on Board.
Definition board.hpp:325
Turn(const Piece *tpiece, const Position &to, const Piece *cap=nullptr, bool possible=true)
Construct new Turn object.
Definition turn.cpp:8
Generic board memeber API.
Definition board.hpp:23
Piece(const Position &pos={1, 1}, Color col=Color::White)
Construct new Piece.
Definition piece.cpp:6
Color
Piece color.
Definition board.hpp:30
Bishop Turn.
Definition chess.hpp:352
bool isEqual(const Piece::Turn &) const override
Compare turns.
Bishop chess Piece.
Definition chess.hpp:343
virtual TurnMap moveMap(int mode=0) const override
Generic moves.
Definition bishop.cpp:7
Chess game board.
Definition chess.hpp:22
King * currentKing()
King that has the color of currentTurn()
Definition chess.hpp:161
const King * whiteKing() const
Current White King.
Definition chess.hpp:140
King * blackKing()
Current Black King.
Definition chess.hpp:155
King * c_currentEnemyKing
Current enemy King object.
Definition chess.hpp:282
virtual std::string str() const override
String represeantation of current Chessboard.
Definition chess.cpp:192
PieceSetT defaultPieceSet() const override
Get default chessboard Piece set.
Definition chess.cpp:160
virtual Piece * piece(const std::string &spec) const override
Convert std::string Piece spec to actual Piece object pointer.
Definition chess.cpp:13
Mode
Modes to use with Turn::apply and Piece::moveMap.
Definition chess.hpp:226
@ CheckingMode
Apply the turn or produce moveMap as performing the validation for King check.
Definition chess.hpp:241
@ DefaultMode
Default mode. Act as usual.
Definition chess.hpp:227
virtual Piece * canInsert(Piece *p) const override
Throws an exception if Piece cannot be placed at the Board.
Definition chess.cpp:74
King * currentEnemyKing()
King that has the color opposite to currentTurn()
Definition chess.hpp:177
const King * blackKing() const
Current Black King.
Definition chess.hpp:151
virtual Piece::Color setCurrentTurn(Piece::Color) override
Set current turn Color.
Definition chess.cpp:138
King * c_currentKing
Current King object.
Definition chess.hpp:272
const King * currentKing() const
King that has the color of currentTurn()
Definition chess.hpp:165
King * c_whiteKing
White King object.
Definition chess.hpp:258
virtual void clear() override
Clear current Chessboard.
Definition chess.cpp:152
void markChecks(Piece::TurnMap &map) const
Marks Tunr objects that will put current King in check.
Definition chess.cpp:127
virtual Piece * insertPiece(Piece *p) override
Place piece on Board.
Definition chess.cpp:91
virtual bool isEqual(const Board &) const override
Compare 2 Board objects.
Definition chess.cpp:231
virtual const Piece::Turn * makeTurn(const Piece::Position &from, const Piece::Position &to) override
Make turn on Chessboard.
Definition chess.cpp:114
King * c_blackKing
Black King object.
Definition chess.hpp:264
King * whiteKing()
Current White King.
Definition chess.hpp:144
virtual Piece::TurnMap possibleMoves(const Piece *) const override
Possible moves of a Piece by it's adress.
Definition chess.cpp:108
const King * currentEnemyKing() const
King that has the color opposite to currentTurn()
Definition chess.hpp:173
King Turn.
Definition chess.hpp:406
virtual std::string str() const override
String Turn representation.
virtual void undo() override
Undo turn.
bool isEqual(const Piece::Turn &) const override
Compare turns.
Turn(const Piece *f, const Position &t, const Piece *c=nullptr, Rook::Turn *castling=nullptr, bool p=true)
Make new King Turn object.
Definition chess.hpp:420
virtual void apply(int mode=0) override
Apply turn.
King chess Piece.
Definition chess.hpp:397
bool castled() const
Has the King object already performed the castling Turn.
Definition chess.hpp:461
bool checkmate() const
Check if a King is under checkmate.
Definition king.cpp:109
bool check() const
Check if a King is under check.
Definition king.cpp:74
virtual TurnMap moveMap(int mode=0) const override
Generic moves.
Definition king.cpp:9
Knight Turn.
Definition chess.hpp:334
bool isEqual(const Piece::Turn &) const override
Compare turns.
Knight chess Piece.
Definition chess.hpp:323
virtual TurnMap moveMap(int mode=0) const override
Generic moves.
Definition knight.cpp:7
Pawn Turn.
Definition chess.hpp:302
bool isEqual(const Piece::Turn &) const override
Compare turns.
virtual void apply(int mode=0) override
Apply turn.
const std::type_index & promoteTo() const
Get prometion Piece type.
Definition chess.hpp:318
Pawn chess Piece.
Definition chess.hpp:286
virtual TurnMap moveMap(int mode=0) const override
Moves of a Pawn object.
Definition pawn.cpp:7
Queen Turn.
Definition chess.hpp:388
bool isEqual(const Piece::Turn &) const override
Compare turns.
Queen chess Piece.
Definition chess.hpp:379
virtual TurnMap moveMap(int mode=0) const override
Generic moves.
Definition queen.cpp:7
Rook Turn.
Definition chess.hpp:370
bool isEqual(const Piece::Turn &) const override
Compare turns.
Rook chess Piece.
Definition chess.hpp:361
virtual TurnMap moveMap(int mode=0) const override
Generic moves.
Definition rook.cpp:7
Chess game namespace.
Definition chess.cpp:7