src/chess/pawn.c

changeset 163
2a6d83f4677e
parent 160
f87832cba8b8
equal deleted inserted replaced
162:f0fc70b6f8f9 163:2a6d83f4677e
28 */ 28 */
29 29
30 #include "pawn.h" 30 #include "pawn.h"
31 #include "rules.h" 31 #include "rules.h"
32 32
33 bool pawn_chkrules(GameState *gamestate, Move *move) { 33 bool pawn_chkrules(const GameState *gamestate, const Move *move) {
34 int8_t d = piece_color(move->piece) == WHITE ? -1 : 1; 34 int8_t d = piece_color(move->piece) == WHITE ? -1 : 1;
35 35
36 if (move->torow == (d < 0 ? 7 : 0)) { 36 if (move->torow == (d < 0 ? 7 : 0)) {
37 if (move->promotion) { 37 if (move->promotion) {
38 unsigned ppiecetype = piece_type(move->promotion); 38 unsigned ppiecetype = piece_type(move->promotion);
67 return false; 67 return false;
68 } 68 }
69 } 69 }
70 } 70 }
71 71
72 bool pawn_isblocked(GameState *gamestate, Move *move) { 72 bool pawn_isblocked(const GameState *gamestate, const Move *move) {
73 if (move->torow == move->fromrow + 1 || move->torow == move->fromrow - 1) { 73 if (move->torow == move->fromrow + 1 || move->torow == move->fromrow - 1) {
74 return piece_at(gamestate, mdst(move)) && !move->capture; 74 return piece_at(gamestate, mdst(move)) && !move->capture;
75 } else { 75 } else {
76 return piece_at(gamestate, mdst(move)) || 76 return piece_at(gamestate, mdst(move)) ||
77 gamestate->board[(move->fromrow+move->torow)/2][move->tofile]; 77 gamestate->board[(move->fromrow+move->torow)/2][move->tofile];

mercurial