99 isidx((move)->tofile) && isidx((move)->torow)) |
114 isidx((move)->tofile) && isidx((move)->torow)) |
100 |
115 |
101 /* secure versions - use, if index is not checked with isidx() */ |
116 /* secure versions - use, if index is not checked with isidx() */ |
102 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
117 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
103 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
118 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
|
119 |
|
120 void gamestate_cleanup(GameState *gamestate); |
104 |
121 |
105 /** |
122 /** |
106 * Maps a character to a piece. |
123 * Maps a character to a piece. |
107 * |
124 * |
108 * Does not work for pawns, since they don't have a character. |
125 * Does not work for pawns, since they don't have a character. |
124 |
141 |
125 /** |
142 /** |
126 * Evaluates a move syntactically and stores the move data in the specified |
143 * Evaluates a move syntactically and stores the move data in the specified |
127 * object. |
144 * object. |
128 * |
145 * |
129 * @param board the current state of the board |
146 * @param gamestate the current game state |
130 * @param mycolor the color of the current player |
|
131 * @param mstr the input string to parse |
147 * @param mstr the input string to parse |
132 * @param move a pointer to object where the move data shall be stored |
148 * @param move a pointer to object where the move data shall be stored |
133 * @return status code (see rules/rules.h for the list of codes) |
149 * @return status code (see rules/rules.h for the list of codes) |
134 */ |
150 */ |
135 int eval_move(Board board, uint8_t mycolor, char *mstr, Move *move); |
151 int eval_move(GameState *gamestate, char *mstr, Move *move); |
136 |
152 |
137 /** |
153 /** |
138 * Validates move by applying chess rules. |
154 * Validates move by applying chess rules. |
139 * @param board the current board state |
155 * @param gamestate the current game state |
140 * @param move the move to validate |
156 * @param move the move to validate |
141 * @return TRUE, if the move complies to chess rules, FALSE otherwise |
157 * @return TRUE, if the move complies to chess rules, FALSE otherwise |
142 */ |
158 */ |
143 _Bool validate_move(Board board, Move *move); |
159 _Bool validate_move(GameState *gamestate, Move *move); |
144 |
160 |
145 /** |
161 /** |
146 * Applies a move and deletes captured pieces. |
162 * Applies a move and deletes captured pieces. |
147 * |
163 * |
148 * @param board the current board state |
164 * @param gamestate the current game state |
149 * @param move the move to apply |
165 * @param move the move to apply |
150 */ |
166 */ |
151 void apply_move(Board board, Move *move); |
167 void apply_move(GameState *gamestate, Move *move); |
152 |
168 |
153 #endif /* RULES_H */ |
169 #endif /* RULES_H */ |
154 |
170 |