diff -r 4d030da07c88 -r 3ab0c2e1a4e2 src/chess/rules.h --- a/src/chess/rules.h Tue Apr 01 10:28:08 2014 +0200 +++ b/src/chess/rules.h Tue Apr 01 12:30:25 2014 +0200 @@ -95,6 +95,8 @@ MoveList* lastmove; } GameState; +#define opponent_color(color) ((color)==WHITE?BLACK:WHITE) + #define POS_UNSPECIFIED UINT8_MAX #define mdst(b,m) b[(m)->torow][(m)->tofile] #define msrc(b,m) b[(m)->fromrow][(m)->fromfile] @@ -140,6 +142,18 @@ char getpiecechr(uint8_t piece); /** + * Checks, if a specified field is covered by a piece of a certain color. + * + * @param gamestate the current game state + * @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 cover the field + * @return TRUE, if any piece of the specified color threatens the specified + * field (i.e. could capture an opponent piece) + */ +_Bool is_covered(GameState *gamestate,uint8_t row,uint8_t file,uint8_t color); + +/** * Evaluates a move syntactically and stores the move data in the specified * object. *