Projects/khet
Projects
/
khet
Archived
6
0
Fork 0

color-restricted squares

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2008-10-10 12:09:18 +00:00
parent c0395e561c
commit 716cfbc50e
1 changed files with 15 additions and 0 deletions

View File

@ -123,6 +123,18 @@ ret:
return retval;
}
int
square_allowed(int x, int y, int side)
{
if (x == 0 && side == SILVER) return 0;
if (x == BOARD_WIDTH-1 && side == RED) return 0;
if (y == 0 || y == BOARD_HEIGHT-1) {
if (x == 1 && side == RED) return 0;
if (x == BOARD_WIDTH-2 && side == SILVER) return 0;
}
return 1;
}
int
movable(game_t *game, int row, int col, int side)
{
@ -174,6 +186,9 @@ move(game_t *game, int side, int row, int col, int dir, int flags) {
return HUGE_SUCCESS;
}
if (!square_allowed(ncol, nrow, side))
return E_ILLEGAL_MOVE;
if (game->board[ncol][nrow].piece &&
!((game->board[col][row].piece == DJHED) &&
((game->board[ncol][nrow].piece != DJHED) &&