| 58 |
58 |
| 59 return false; |
59 return false; |
| 60 } |
60 } |
| 61 |
61 |
| 62 size_t rook_moves(const GameState *gamestate, |
62 size_t rook_moves(const GameState *gamestate, |
| 63 Color c, Rank r, File f, Move *moves) { |
63 Color c, File f, Rank r, Move *moves) { |
| 64 size_t count = 0; |
64 size_t count = 0; |
| 65 const int directions[4][2] = { |
65 const int directions[4][2] = { |
| 66 { 1, 0}, |
66 { 1, 0}, |
| 67 {-1, 0}, |
67 {-1, 0}, |
| 68 { 0, 1}, |
68 { 0, 1}, |
| 78 moves[count].piece = mkpiece(ROOK, c); |
78 moves[count].piece = mkpiece(ROOK, c); |
| 79 moves[count].fromrank = r; |
79 moves[count].fromrank = r; |
| 80 moves[count].fromfile = f; |
80 moves[count].fromfile = f; |
| 81 moves[count].torank = rank; |
81 moves[count].torank = rank; |
| 82 moves[count].tofile = file; |
82 moves[count].tofile = file; |
| 83 moves[count].capture = piece_at(gamestate, rank, file) != 0; |
83 moves[count].capture = piece_at(gamestate, file, rank) != 0; |
| 84 count++; |
84 count++; |
| 85 |
85 |
| 86 rank += directions[i][0]; |
86 rank += directions[i][0]; |
| 87 file += directions[i][1]; |
87 file += directions[i][1]; |
| 88 } |
88 } |