1.1 --- a/src/chess/rules.h Wed Jun 11 16:54:20 2014 +0200 1.2 +++ b/src/chess/rules.h Mon Jun 16 13:45:31 2014 +0200 1.3 @@ -110,11 +110,12 @@ 1.4 1.5 typedef struct { 1.6 Board board; 1.7 - uint8_t mycolor; 1.8 MoveList* movelist; 1.9 MoveList* lastmove; 1.10 _Bool checkmate; 1.11 _Bool stalemate; 1.12 + _Bool remis; 1.13 + _Bool resign; 1.14 } GameState; 1.15 1.16 #define opponent_color(color) ((color)==WHITE?BLACK:WHITE) 1.17 @@ -141,6 +142,16 @@ 1.18 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) 1.19 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) 1.20 1.21 +#define is_game_running(gamestate) !((gamestate)->checkmate || \ 1.22 + (gamestate)->resign || (gamestate)->stalemate || (gamestate)->remis) 1.23 + 1.24 + 1.25 +/** 1.26 + * Initializes a game state and prepares the chess board. 1.27 + * @param gamestate the game state to initialize 1.28 + */ 1.29 +void gamestate_init(GameState *gamestate); 1.30 + 1.31 /** 1.32 * Cleans up a game state and frees the memory for the movement list. 1.33 * @param gamestate the game state to clean up 1.34 @@ -276,9 +287,10 @@ 1.35 * @param gamestate the current game state 1.36 * @param mstr the input string to parse 1.37 * @param move a pointer to object where the move data shall be stored 1.38 + * @param color the color of the player to evaluate the move for 1.39 * @return status code (see macros in this file for the list of codes) 1.40 */ 1.41 -int eval_move(GameState *gamestate, char *mstr, Move *move); 1.42 +int eval_move(GameState *gamestate, char *mstr, Move *move, uint8_t color); 1.43 1.44 /** 1.45 * Validates move by applying chess rules.