summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-08-18 09:36:58 +0300
committereug-vs <eugene@eug-vs.xyz>2022-08-18 09:36:58 +0300
commitca2fc17834207b501b66d5c713889de029da27d6 (patch)
treea0a66e9aeefebc8e3d760c3ae1bce6619c4f8f23 /src/main.c
parent33de5e1bbcb57469b16b29bf0e207453ead9ea3e (diff)
downloadc-chess-ca2fc17834207b501b66d5c713889de029da27d6.tar.gz
feat: improve pawn movement
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 8181d7c..b18c7ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -141,8 +141,15 @@ int validate_move(int move[2], int color, int* board) {
legal_move = kingMoves;
break;
case PAWN:
- if (piece & BLACK) legal_move = blackPawnMoves;
- else legal_move = pawnMoves;
+ if (piece & BLACK) {
+ if (board[destination] != EMPTY) legal_move = blackPawnAttackMoves;
+ else if (origin >> 4 == 6) legal_move = newBlackPawnMoves;
+ else legal_move = blackPawnMoves;
+ } else {
+ if (board[destination] != EMPTY) legal_move = pawnAttackMoves;
+ else if (origin >> 4 == 1) legal_move = newPawnMoves;
+ else legal_move = pawnMoves;
+ }
break;
default:
return -2;