Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 7169a365 rédigé par Jessica RADAFY's avatar Jessica RADAFY
Parcourir les fichiers

Mise a jour

parent 08adaa22
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -312,15 +312,17 @@ export function princessMove(board: Chessboard, move: Move): boolean {
let start: Square = squareAtPosition(board, move.from!);
// Validation of movement to move in diagonal
// Check that there is no pawn between origin square and the destination square
if (Math.abs(move.from!.rank - move.to!.rank) === Math.abs(move.from!.file - move.to!.file))
{
// Check that "destination square is empty or the color of the piece that is on the origin square
// is different than the color of the piece which is on the destination square" is true
return (destination.isEmpty||destination.piece!.isWhite !== start.piece!.isWhite);
}
// Valdation of movement to move in "L"
// Check that there is no pawn between origin square and the destination square
const filedifference : number = start.position.file - destination.position.file;
const rankdifference : number = start.position.rank - destination.position.rank;
// Le if vérifie que la valeur absolue des différences sont égales,ce qui premet de savoir si la trajectoire
// est diagonale, et si cette dernière est vide.
if ((Math.abs(filedifference) == Math.abs(rankdifference)) && (isEmptyDiagonale(board, move)==true)){
return (destination.isEmpty || destination.piece!.isWhite !== start.piece!.isWhite);
}
// Validation of movement to move in "L"
if (equals(move.to!, left(top(top(move.from!)))) ||
equals(move.to!, left(bottom(bottom(move.from!)))) ||
equals(move.to!, right(top(top(move.from!)))) ||
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter