1
0
mirror of https://github.com/taigrr/JSCheckers synced 2025-01-18 04:33:13 -08:00

Removed ability to capture backwards except for in coomplex moves

This commit is contained in:
Tai Groot 2015-08-17 14:57:50 -07:00
parent e7188d58bb
commit 7a86cc9ad0

View File

@ -175,31 +175,36 @@ function movePiece(idName, XCoor, YCoor)
} }
else if(((multPossible&&(lastUsed==(fromCol+'a'+fromRow)))||((fromType).substring(0,1)!=lastPlayer.substring(0,1)))&&(Math.abs(toRow-fromRow)<3)&&(Math.abs(toCol-fromCol)<3)&&((avType=='red')||(avType=='redK')||(avType=='black')||(avType=='blackK'))) else if(((multPossible&&(lastUsed==(fromCol+'a'+fromRow)))||((fromType).substring(0,1)!=lastPlayer.substring(0,1)))&&(Math.abs(toRow-fromRow)<3)&&(Math.abs(toCol-fromCol)<3)&&((avType=='red')||(avType=='redK')||(avType=='black')||(avType=='blackK')))
{ {
if(fromType=='black'||fromType=='blackK') if((!(((fromType=='red')&&(toRow<fromRow))||((fromType=='black')&&(toRow>fromRow))))||(multPossible&&(lastUsed==(fromCol+'a'+fromRow))))
{ {
if(avType=='red'||avType=='redK')
if(fromType=='black'||fromType=='blackK')
{ {
arrSquares[avRow][avCol].type='empty'; if(avType=='red'||avType=='redK')
{
arrSquares[avRow][avCol].type='empty';
}
arrSquares[toRow][toCol].type = arrSquares[fromRow][fromCol].type;
arrSquares[fromRow][fromCol].type = 'empty';
playSound('Knock');
lastUsed = toCoorString;
lastPlayer = arrSquares[toRow][toCol].type;
multPossible = true;
} }
arrSquares[toRow][toCol].type = arrSquares[fromRow][fromCol].type; else
arrSquares[fromRow][fromCol].type = 'empty';
playSound('Knock');
lastUsed = toCoorString;
lastPlayer = arrSquares[toRow][toCol].type;
multPossible = true;
}
else
{
if(avType=='black'||avType=='blackK')
{ {
arrSquares[avRow][avCol].type='empty'; if(avType=='black'||avType=='blackK')
} {
arrSquares[toRow][toCol].type = arrSquares[fromRow][fromCol].type; arrSquares[avRow][avCol].type='empty';
arrSquares[fromRow][fromCol].type = 'empty'; }
playSound('Knock'); arrSquares[toRow][toCol].type = arrSquares[fromRow][fromCol].type;
lastUsed = toCoorString; arrSquares[fromRow][fromCol].type = 'empty';
lastPlayer = arrSquares[toRow][toCol].type; playSound('Knock');
multPossible=true; lastUsed = toCoorString;
lastPlayer = arrSquares[toRow][toCol].type;
multPossible=true;
}
} }
} }
} }