src/chess/rules.h

changeset 168
663676cfef6e
parent 167
fd1d3f0a7a73
--- a/src/chess/rules.h	Sun Aug 02 15:08:43 2026 +0200
+++ b/src/chess/rules.h	Sun Aug 02 15:19:47 2026 +0200
@@ -291,6 +291,7 @@
  * Determines a list of theoretically possible moves to the specified field.
  *
  * This will also list moves for pieces that are actually pinned.
+ * Use get_real_candidates() to get only moves for pieces that are not pinned.
  *
  * The out-parameters may both be NULL, but if any of them is set, the other
  * must be set, too.
@@ -309,6 +310,29 @@
         Color color, Move* moves, size_t* movecount);
 
 /**
+ * Determines a list of possible moves to the specified field.
+ *
+ * This cannot be used to check if a piece covers / threatens a field because
+ * this is also possible when the piece is pinned. Use get_candidates() for a
+ * list of possible moves regardless of pins.
+ *
+ * The out-parameters may both be NULL, but if any of them is set, the other
+ * must be set, too.
+ *
+ * @param gamestate the current game state
+ * @param row row of the field to check
+ * @param file file of the field to check
+ * @param color the color of the piece that should move to the field
+ * @param moves the array where to store the moves
+ * (must be large enough, 16 is always enough)
+ * @param movecount a pointer where the number of moves is stored
+ * @return true, if any piece of the specified color can move to the specified
+ * field and is not pinned
+ */
+bool get_real_candidates(const GameState *gamestate, Row row, File file,
+        Color color, Move* moves, size_t* movecount);
+
+/**
  * Checks, if a specified field is threatened by a piece of a certain color.
  *
  * A field is threatened, if there is a piece of the specified color that could

mercurial