Skip to content

Commit

Permalink
Always set castling statuses to false when the king moves, not only w…
Browse files Browse the repository at this point in the history
…hen castling.
  • Loading branch information
fornwall committed Oct 24, 2012
1 parent 9f559a7 commit 30bbecc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/chess.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,33 @@ aux_chess_apply_candidate_move(chess_game_status *s)
{
s->b[5][0] = 'R';
s->b[7][0] = ' ';
s->c[0] = 'n';
s->c[1] = 'n';
}
if (s->b[x1][y1] == 'K' && x1 == 4 && x2 == 2)
{
s->b[3][0] = 'R';
s->b[0][0] = ' ';
s->c[0] = 'n';
s->c[1] = 'n';
}
if (s->b[x1][y1] == 'k' && x1 == 4 && x2 == 6)
{
s->b[5][7] = 'r';
s->b[7][7] = ' ';
s->c[2] = 'n';
s->c[3] = 'n';
}
if (s->b[x1][y1] == 'k' && x1 == 4 && x2 == 2)
{
s->b[3][7] = 'r';
s->b[0][7] = ' ';
}

/*
* Moving a King waives the castling status of its castles.
*/
if (s->b[x1][y1] == 'K')
{
s->c[0] = 'n';
s->c[1] = 'n';
}
if (s->b[x1][y1] == 'k')
{
s->c[2] = 'n';
s->c[3] = 'n';
}
Expand Down

0 comments on commit 30bbecc

Please sign in to comment.