tartan 1.2.2.1
Chess API
Loading...
Searching...
No Matches
exceptions.hpp
1#ifndef _TARTAN_CHESS_EXCEPTIONS_HPP_
2#define _TARTAN_CHESS_EXCEPTIONS_HPP_
3
4#include <tartan/chess.hpp>
5#include <tartan/board/exceptions.hpp>
6
7#include <string>
8
10namespace tt::chess::ex {
11
16public:
18 const Piece* p,
19 const std::string& what_arg = "Board already has a king"
20 ) : bad_piece(p, what_arg) {};
21};
22
27class no_king : public tt::ex::tartan {
28public:
36 const std::string& what_arg = "Board does not have a king"
37 ) : tartan(what_arg) { e_color = c; };
38 Piece::Color e_color;
44 Piece::Color color() const { return e_color; };
45};
46
53public:
60 const Piece* p,
61 const Piece::Position& to,
62 const Piece* k,
63 const std::string& what_arg = "King is under check after move")
64 : illegal_move(p, to, what_arg) { e_king = k; };
66 const Piece* king() const { return e_king; };
67private:
68 const Piece* e_king;
69};
70
76class checkmate : public check {
77public:
82 const Piece* p,
83 const Piece::Position& to,
84 const Piece* k,
85 const std::string& what_arg = "King is under checkmate")
86 : check(p, to, k, what_arg) {};
87};
88
89}
90
91#endif // !_TARTAN_CHESS_EXCEPTIONS_HPP_
Piece position at the Board.
Definition board.hpp:36
Generic board memeber API.
Definition board.hpp:23
Color
Piece color.
Definition board.hpp:30
Thrown when turn cannot be perfomred because of King beeing in check.
Definition exceptions.hpp:52
check(const Piece *p, const Piece::Position &to, const Piece *k, const std::string &what_arg="King is under check after move")
Definition exceptions.hpp:59
const Piece * king() const
Get the King object.
Definition exceptions.hpp:66
Thrown when turn cannot be perfomred because of King is under checkmate.
Definition exceptions.hpp:76
checkmate(const Piece *p, const Piece::Position &to, const Piece *k, const std::string &what_arg="King is under checkmate")
Definition exceptions.hpp:81
Thrown when inserted King is already provided.
Definition exceptions.hpp:15
Thrown when tt::chess::Chessboard has no King object of certain tt::Piece::Color.
Definition exceptions.hpp:27
no_king(Piece::Color c, const std::string &what_arg="Board does not have a king")
Definition exceptions.hpp:34
Piece::Color color() const
Get the King color.
Definition exceptions.hpp:44
Base class for exceptions about pieces.
Definition exceptions.hpp:38
bad_piece(const Piece *p, const std::string &what_arg="Invalid piece")
Definition exceptions.hpp:44
Base class for Board::makeMove() function errors.
Definition exceptions.hpp:141
const Piece::Position & to() const
Get move target location.
Definition exceptions.hpp:166
illegal_move(const Piece *p, const Piece::Position &to, const std::string &what_arg="Illegal move")
Definition exceptions.hpp:149
Base class for all tartan exceptions.
Definition exceptions.hpp:18
Chess related exceptions namespace.
Definition exceptions.hpp:10