| 285 */ |
285 */ |
| 286 static inline void piece_remove(GameState *gamestate, Row row, File file) { |
286 static inline void piece_remove(GameState *gamestate, Row row, File file) { |
| 287 piece_set(gamestate, row, file, 0); |
287 piece_set(gamestate, row, file, 0); |
| 288 } |
288 } |
| 289 |
289 |
| 290 typedef size_t(*moves_generator_func)(GameState *gamestate, |
290 typedef size_t(*moves_generator_func)(const GameState *gamestate, |
| 291 Color c, Row r, File f, Move *moves); |
291 Color c, Row r, File f, Move *moves); |
| |
292 |
| |
293 /** |
| |
294 * Calculates all allowed moves for a specific piece. |
| |
295 * |
| |
296 * Use the macros for the specific pieces instead. |
| |
297 * |
| |
298 * @param gamestate the current gamestate |
| |
299 * @param r the row of the piece |
| |
300 * @param f the file of the piece |
| |
301 * @param moves target array for the list of moves |
| |
302 * @return the number of moves stored in the @p moves array |
| |
303 */ |
| |
304 size_t piece_moves_allowed(const GameState *gamestate, |
| |
305 Row r, File f, Move *moves); |
| 292 |
306 |
| 293 /** |
307 /** |
| 294 * Internal function used to filter out illegal moves. |
308 * Internal function used to filter out illegal moves. |
| 295 * |
309 * |
| 296 * Use the macros for the specific pieces instead. |
310 * Use the macros for the specific pieces instead. |
| 301 * @param f the file of the piece |
315 * @param f the file of the piece |
| 302 * @param moves target array for the list of moves |
316 * @param moves target array for the list of moves |
| 303 * @param func a function that unconditionally generates the moves |
317 * @param func a function that unconditionally generates the moves |
| 304 * @return the number of moves stored in the @p moves array |
318 * @return the number of moves stored in the @p moves array |
| 305 */ |
319 */ |
| 306 size_t filter_moves_allowed(GameState *gamestate, |
320 size_t filter_moves_allowed(const GameState *gamestate, |
| 307 Color c, Row r, File f, Move *moves, moves_generator_func func); |
321 Color c, Row r, File f, Move *moves, moves_generator_func func); |
| 308 |
322 |
| 309 /** |
323 /** |
| 310 * Determines a list of theoretically possible moves to the specified field. |
324 * Determines a list of theoretically possible moves to the specified field. |
| 311 * |
325 * |