src/chess/rook.c

changeset 194
619f07c95894
parent 170
bde99d803caf
child 195
27d02ccb0cef
--- a/src/chess/rook.c	Tue Aug 25 18:35:18 2026 +0200
+++ b/src/chess/rook.c	Tue Aug 25 18:59:18 2026 +0200
@@ -31,24 +31,24 @@
 #include "rook.h"
 
 bool rook_chkrules(const Move *move) {
-    return move->torow == move->fromrow || move->tofile == move->fromfile;
+    return move->torank == move->fromrank || move->tofile == move->fromfile;
 }
 
 bool rook_isblocked(const GameState *gamestate, const Move *move) {
     
-    if (move->torow == move->fromrow) {
+    if (move->torank == move->fromrank) {
         int d = move->tofile > move->fromfile ? 1 : -1;
-        uint8_t f = move->fromfile;
+        File f = move->fromfile;
         while (f != move->tofile-d) {
             f += d;
-            if (gamestate->board[move->fromrow][f]) {
+            if (gamestate->board[move->fromrank][f]) {
                 return true;
             }
         }
     } else {
-        int d = move->torow > move->fromrow ? 1 : -1;
-        uint8_t r = move->fromrow;
-        while (r != move->torow - d) {
+        int d = move->torank > move->fromrank ? 1 : -1;
+        Rank r = move->fromrank;
+        while (r != move->torank - d) {
             r += d;
             if (gamestate->board[r][move->fromfile]) {
                 return true;
@@ -60,7 +60,7 @@
 }
 
 size_t rook_moves(const GameState *gamestate,
-        Color c, Row r, File f, Move *moves) {
+        Color c, Rank r, File f, Move *moves) {
     size_t count = 0;
     const int directions[4][2] = {
         { 1,  0},
@@ -70,20 +70,20 @@
     };
 
     for (size_t i = 0 ; i < 4 ; i++) {
-        int row = r + directions[i][0];
-        int file = f + directions[i][1];
+        Rank rank = r + directions[i][0];
+        File file = f + directions[i][1];
 
-        while (isidx(row) && isidx(file)) {
+        while (isidx(rank) && isidx(file)) {
             moves[count] = (Move){0};
             moves[count].piece = mkpiece(ROOK, c);
-            moves[count].fromrow = r;
+            moves[count].fromrank = r;
             moves[count].fromfile = f;
-            moves[count].torow = row;
+            moves[count].torank = rank;
             moves[count].tofile = file;
-            moves[count].capture = piece_at(gamestate, row, file) != 0;
+            moves[count].capture = piece_at(gamestate, rank, file) != 0;
             count++;
 
-            row += directions[i][0];
+            rank += directions[i][0];
             file += directions[i][1];
         }
     }

mercurial