diff -r 4dcfb4c58b6d -r d726e4b46c33 src/chess/rules.h --- a/src/chess/rules.h Thu Apr 17 12:16:14 2014 +0200 +++ b/src/chess/rules.h Wed May 28 15:47:57 2014 +0200 @@ -38,6 +38,8 @@ #define INVALID_POSITION 2 #define AMBIGUOUS_MOVE 3 #define NEED_PROMOTION 4 +#define PIECE_PINNED 5 +#define KING_IN_CHECK 6 #define PIECE_MASK 0x0F @@ -167,9 +169,10 @@ * @param row row of the field to check * @param file file of the field to check * @param color the color of the piece that should threaten the field - * @param threats the array where to store the threats (should be able to the - * rare maximum of 16 elements) - * @param threatcount a pointer to an uint8_t where to store the amount of threats + * @param threats the array where to store the threats (should be able to hold + * the rare maximum of 16 elements) + * @param threatcount a pointer to an uint8_t where the count of threats is + * stored * @return TRUE, if any piece of the specified color threatens the specified * field (i.e. could capture an opponent piece) */ @@ -187,9 +190,10 @@ * @param row row of the field to check * @param file file of the field to check * @param color the color of the piece that should threaten the field - * @param threats the array where to store the threats (should be able to the - * rare maximum of 16 elements) - * @param threatcount a pointer to an uint8_t where to store the amount of threats + * @param threats the array where to store the threats (should be able to hold + * the rare maximum of 16 elements) + * @param threatcount a pointer to an uint8_t where the count of threats is + * stored * @return TRUE, if any piece of the specified color threatens the specified * field (i.e. could capture an opponent piece) */ @@ -242,6 +246,22 @@ uint8_t color); /** + * Checks, if the specified move cannot be performed, because the piece is + * either pinned or cannot remove the check. + * + * Note: in chess a piece is pinned, when it can't be moved because the move + * would result in a check position. But this function also returns true, + * if the king is already in check position and the specified move does not + * protect the king. + * + * @param gamestate the current game state + * @param move the move to check + * @return TRUE, if the move cannot be performed because the king would be in + * check after the move + */ +_Bool is_pinned(GameState *gamestate, Move *move); + +/** * Evaluates a move syntactically and stores the move data in the specified * object. *