diff -r 02c509a44e98 -r 41017d0a72c5 src/chess/rules.h --- a/src/chess/rules.h Wed Jun 11 16:54:20 2014 +0200 +++ b/src/chess/rules.h Mon Jun 16 13:45:31 2014 +0200 @@ -110,11 +110,12 @@ typedef struct { Board board; - uint8_t mycolor; MoveList* movelist; MoveList* lastmove; _Bool checkmate; _Bool stalemate; + _Bool remis; + _Bool resign; } GameState; #define opponent_color(color) ((color)==WHITE?BLACK:WHITE) @@ -141,6 +142,16 @@ #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) +#define is_game_running(gamestate) !((gamestate)->checkmate || \ + (gamestate)->resign || (gamestate)->stalemate || (gamestate)->remis) + + +/** + * Initializes a game state and prepares the chess board. + * @param gamestate the game state to initialize + */ +void gamestate_init(GameState *gamestate); + /** * Cleans up a game state and frees the memory for the movement list. * @param gamestate the game state to clean up @@ -276,9 +287,10 @@ * @param gamestate the current game state * @param mstr the input string to parse * @param move a pointer to object where the move data shall be stored + * @param color the color of the player to evaluate the move for * @return status code (see macros in this file for the list of codes) */ -int eval_move(GameState *gamestate, char *mstr, Move *move); +int eval_move(GameState *gamestate, char *mstr, Move *move, uint8_t color); /** * Validates move by applying chess rules.