color-restricted squares
This commit is contained in:
parent
c0395e561c
commit
716cfbc50e
15
src/game.c
15
src/game.c
@ -123,6 +123,18 @@ ret:
|
|||||||
return retval;
|
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
|
int
|
||||||
movable(game_t *game, int row, int col, int side)
|
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;
|
return HUGE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!square_allowed(ncol, nrow, side))
|
||||||
|
return E_ILLEGAL_MOVE;
|
||||||
|
|
||||||
if (game->board[ncol][nrow].piece &&
|
if (game->board[ncol][nrow].piece &&
|
||||||
!((game->board[col][row].piece == DJHED) &&
|
!((game->board[col][row].piece == DJHED) &&
|
||||||
((game->board[ncol][nrow].piece != DJHED) &&
|
((game->board[ncol][nrow].piece != DJHED) &&
|
||||||
|
Reference in New Issue
Block a user