src/chess/king.c

changeset 193
d1420f5c5704
parent 170
bde99d803caf
child 194
619f07c95894
equal deleted inserted replaced
192:e57e2874fb2a 193:d1420f5c5704
64 } 64 }
65 } 65 }
66 66
67 bool king_isblocked(const GameState *gamestate, const Move *move) { 67 bool king_isblocked(const GameState *gamestate, const Move *move) {
68 68
69 uint8_t opponent_color = opponent_color(piece_color(move->piece)); 69 uint8_t op_color = opponent_color(piece_color(move->piece));
70 70
71 /* being in check does not "block" the king, so don't test it here */ 71 /* being in check does not "block" the king, so don't test it here */
72 bool blocked = false; 72 bool blocked = false;
73 73
74 /* just test, if castling move is blocked */ 74 /* just test, if castling move is blocked */
80 bool incheck = false; 80 bool incheck = false;
81 if (gamestate->movecount > 0) { 81 if (gamestate->movecount > 0) {
82 incheck = is_check_position(gamestate); 82 incheck = is_check_position(gamestate);
83 } 83 }
84 blocked |= incheck || gamestate->board[move->torow][midfile] || 84 blocked |= incheck || gamestate->board[move->torow][midfile] ||
85 is_covered(gamestate, move->torow, midfile, opponent_color); 85 is_covered(gamestate, move->torow, midfile, op_color);
86 } 86 }
87 87
88 return blocked; 88 return blocked;
89 } 89 }
90 90

mercurial