31 #define RULES_H |
31 #define RULES_H |
32 |
32 |
33 #include <stdint.h> |
33 #include <stdint.h> |
34 #include <sys/time.h> |
34 #include <sys/time.h> |
35 |
35 |
36 #define VALID_MOVE_SYNTAX 0 |
36 #define VALID_MOVE_SYNTAX 0 |
37 #define INVALID_MOVE_SYNTAX 1 |
37 #define VALID_MOVE_SEMANTICS 0 /* use same code for a success */ |
38 #define INVALID_POSITION 2 |
38 #define INVALID_MOVE_SYNTAX 1 |
39 #define AMBIGUOUS_MOVE 3 |
39 #define INVALID_POSITION 2 |
40 #define NEED_PROMOTION 4 |
40 #define AMBIGUOUS_MOVE 3 |
41 #define PIECE_PINNED 5 |
41 #define NEED_PROMOTION 4 |
42 #define KING_IN_CHECK 6 |
42 #define PIECE_PINNED 5 |
|
43 #define KING_IN_CHECK 6 |
|
44 #define KING_MOVES_INTO_CHECK 7 |
|
45 #define RULES_VIOLATED 10 |
43 |
46 |
44 |
47 |
45 #define PIECE_MASK 0x0F |
48 #define PIECE_MASK 0x0F |
46 #define COLOR_MASK 0x30 |
49 #define COLOR_MASK 0x30 |
47 #define ENPASSANT_THREAT 0x40 |
50 #define ENPASSANT_THREAT 0x40 |
266 * object. |
269 * object. |
267 * |
270 * |
268 * @param gamestate the current game state |
271 * @param gamestate the current game state |
269 * @param mstr the input string to parse |
272 * @param mstr the input string to parse |
270 * @param move a pointer to object where the move data shall be stored |
273 * @param move a pointer to object where the move data shall be stored |
271 * @return status code (see rules/rules.h for the list of codes) |
274 * @return status code (see macros in this file for the list of codes) |
272 */ |
275 */ |
273 int eval_move(GameState *gamestate, char *mstr, Move *move); |
276 int eval_move(GameState *gamestate, char *mstr, Move *move); |
274 |
277 |
275 /** |
278 /** |
276 * Validates move by applying chess rules. |
279 * Validates move by applying chess rules. |
277 * @param gamestate the current game state |
280 * @param gamestate the current game state |
278 * @param move the move to validate |
281 * @param move the move to validate |
279 * @return TRUE, if the move complies to chess rules, FALSE otherwise |
282 * @return status code (see macros in this file for the list of codes) |
280 */ |
283 */ |
281 _Bool validate_move(GameState *gamestate, Move *move); |
284 int validate_move(GameState *gamestate, Move *move); |
282 |
285 |
283 /** |
286 /** |
284 * Applies a move and deletes captured pieces. |
287 * Applies a move and deletes captured pieces. |
285 * |
288 * |
286 * @param gamestate the current game state |
289 * @param gamestate the current game state |