-
-
Save Folling/1a632aada1d401c94b772c546e9e6c80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (piece == pawn) | |
{ | |
//check if capture is possible or not | |
if (toLine == line + 1 && (toRow == row + 1 || toRow == row - 1)) | |
{ | |
if (board[toLine][toRow] < 0 || checkForCheck) | |
{ | |
if (toLine == 7) | |
{ | |
board[line][row] = 0; | |
queening(toRow); | |
currentPlayer++; | |
} | |
return true; | |
} | |
else return false; | |
} | |
if (line == 1) | |
{ | |
//if on second rank you can move up to two squares | |
if (toLine > line && toLine - line <= 2 && toLine - line > 0 && toRow == row && board[line + 1][row] == 0 && board[line + 2][row] == 0 && checkForCheck == false) return true; | |
else return false; | |
} | |
else | |
{ | |
if (toLine > line && toLine - 1 == line && toRow == row && board[line + 1][row] == 0 && checkForCheck == false) | |
{ | |
if (toLine == 7) | |
{ | |
board[line][row] = 0; | |
queening(row); | |
currentPlayer++; | |
} | |
return true; | |
} | |
else return false; | |
} | |
} | |
else if (piece == -pawn) | |
{ | |
//checks if capture is possible or not | |
if ((toLine == line - 1 && (toRow == row + 1 || toRow == row - 1))) | |
{ | |
if (board[toLine][toRow] > 0 || checkForCheck) | |
{ | |
if (toLine == 0) | |
{ | |
board[line][row] = 0; | |
queening(toRow); | |
currentPlayer++; | |
} | |
return true; | |
} | |
else return false; | |
} | |
if (line == 6) | |
{ | |
//if on seventh rank you can move up to two squares | |
if (toLine < line && toLine - line >= -2 && toLine - line < 0 && toRow == row && board[line - 1][row] == 0 && board[line - 2][row] == 0 && checkForCheck == false) return true; | |
else return false; | |
} | |
else | |
{ | |
if (toLine < line && toLine + 1 >= line && toRow == row && board[line - 1][row] == 0 && checkForCheck == false) | |
{ | |
if (toLine == 0) | |
{ | |
//checks for whether the pawn is at the lowest rank to allow queening | |
board[line][row] = 0; | |
queening(row); | |
currentPlayer++; | |
} | |
return true; | |
} | |
else return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment