src/chess/rules.h

changeset 48
0cedda2544da
parent 47
d726e4b46c33
child 49
02c509a44e98
     1.1 --- a/src/chess/rules.h	Wed May 28 15:47:57 2014 +0200
     1.2 +++ b/src/chess/rules.h	Wed Jun 11 15:38:01 2014 +0200
     1.3 @@ -33,13 +33,16 @@
     1.4  #include <stdint.h>
     1.5  #include <sys/time.h>
     1.6  
     1.7 -#define VALID_MOVE_SYNTAX   0
     1.8 -#define INVALID_MOVE_SYNTAX 1
     1.9 -#define INVALID_POSITION    2
    1.10 -#define AMBIGUOUS_MOVE      3
    1.11 -#define NEED_PROMOTION      4
    1.12 -#define PIECE_PINNED        5
    1.13 -#define KING_IN_CHECK       6
    1.14 +#define VALID_MOVE_SYNTAX      0
    1.15 +#define VALID_MOVE_SEMANTICS   0 /* use same code for a success */
    1.16 +#define INVALID_MOVE_SYNTAX    1
    1.17 +#define INVALID_POSITION       2
    1.18 +#define AMBIGUOUS_MOVE         3
    1.19 +#define NEED_PROMOTION         4
    1.20 +#define PIECE_PINNED           5
    1.21 +#define KING_IN_CHECK          6
    1.22 +#define KING_MOVES_INTO_CHECK  7
    1.23 +#define RULES_VIOLATED        10
    1.24  
    1.25  
    1.26  #define PIECE_MASK       0x0F
    1.27 @@ -268,7 +271,7 @@
    1.28   * @param gamestate the current game state
    1.29   * @param mstr the input string to parse
    1.30   * @param move a pointer to object where the move data shall be stored
    1.31 - * @return status code (see rules/rules.h for the list of codes)
    1.32 + * @return status code (see macros in this file for the list of codes)
    1.33   */
    1.34  int eval_move(GameState *gamestate, char *mstr, Move *move);
    1.35  
    1.36 @@ -276,9 +279,9 @@
    1.37   * Validates move by applying chess rules.
    1.38   * @param gamestate the current game state
    1.39   * @param move the move to validate
    1.40 - * @return TRUE, if the move complies to chess rules, FALSE otherwise
    1.41 + * @return status code (see macros in this file for the list of codes)
    1.42   */
    1.43 -_Bool validate_move(GameState *gamestate, Move *move);
    1.44 +int validate_move(GameState *gamestate, Move *move);
    1.45  
    1.46  /**
    1.47   * Applies a move and deletes captured pieces.

mercurial