Commit 8ce4e572 authored by Teddy BARKOU's avatar Teddy BARKOU
Browse files

résolution problème fontion findPiece

parent 9d034ad4
......@@ -38,11 +38,11 @@ export function processMove(chessboard:Chessboard, moveString: string): boolean
let move : Move = parseMoveString(moveString);
if (move.isValid && isMovePossible(chessboard, move)) {
performMove(chessboard, move);
whitePlay = !whitePlay;
performMove(chessboard, move);
if(isPossible.isDangerousCase(chessboard,pieces.findPiece(chessboard,pieces.whiteKing).rank,pieces.findPiece(chessboard,pieces.whiteKing).file,true)){
console.log("Echec !");
}
whitePlay = !whitePlay;
} else {
console.log("Invalid movement !");
return false;
......
......@@ -10,31 +10,32 @@ export interface Piece {
}
export const whitePawn : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "Pawn",specialMove:false};
export const whiteKing : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "King",specialMove:false};
export const whiteQueen : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "Queen",specialMove:false};
export const whiteRoock : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "Roock",specialMove:false};
export const whiteKnight : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "Knight",specialMove:false};
export const whiteBishop : Piece = {symbol : "", name: "White Pawn", isWhite : true, type : "Bishop",specialMove:false};
export const whiteKing : Piece = {symbol : "", name: "White King", isWhite : true, type : "King",specialMove:false};
export const whiteQueen : Piece = {symbol : "", name: "White Queen", isWhite : true, type : "Queen",specialMove:false};
export const whiteRoock : Piece = {symbol : "", name: "White Roock", isWhite : true, type : "Roock",specialMove:false};
export const whiteKnight : Piece = {symbol : "", name: "White Knight", isWhite : true, type : "Knight",specialMove:false};
export const whiteBishop : Piece = {symbol : "", name: "White Bishop", isWhite : true, type : "Bishop",specialMove:false};
export const blackPawn : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "Pawn",specialMove:false};
export const blackKing : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "King",specialMove:false};
export const blackKing : Piece = {symbol : "", name: "Black King", isWhite : false, type : "King",specialMove:false};
export const blackQueen : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "Queen",specialMove:false};
export const blackRoock : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "Roock",specialMove:false};
export const blackKnight : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "Knight",specialMove:false};
export const blackBishop : Piece = {symbol : "", name: "Black Pawn", isWhite : false, type : "Bishop",specialMove:false};
export const blackRoock : Piece = {symbol : "", name: "Black Roock", isWhite : false, type : "Roock",specialMove:false};
export const blackKnight : Piece = {symbol : "", name: "Black Knight", isWhite : false, type : "Knight",specialMove:false};
export const blackBishop : Piece = {symbol : "", name: "Black Bishop", isWhite : false, type : "Bishop",specialMove:false};
export function findPiece(board:Chessboard,piece:Piece):Position{
for(let i:number =1;i<8;i++){
for(let j:number = 1;j<8;j++){
for(let i:number =0;i<8;i++){
for(let j:number = 0;j<8;j++){
if(!squareAtPosition(board,position(i,j)).isEmpty){
if (pieceAtPosition(board,position(i,j)).name == piece.name){
return position(i,j);
}
}
}
}
console.log("ffhuehiurfhruifheuifherqifohergrhroigherguerog");
return position(-1,-1);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment