diff --git a/src/deplacement.c b/src/deplacement.c index cb02450b414370b798266e6ba77e0a401e709245..5ac75e210dcbb03d96116781358b5157e60a69ad 100644 --- a/src/deplacement.c +++ b/src/deplacement.c @@ -53,7 +53,7 @@ void case_destination(pile **tableau,int N,int i_src,int j_src, int *i_dest,int for (i=0 ; i<nb ; i++){ switch (tmp->chaine[0]){ case 'P' : - valide=pions(tableau,i_src,j_src,*i_dest,*j_dest,*tour); + valide=pions(tableau,N,i_src,j_src,*i_dest,*j_dest,*tour); break; case 'R' : valide=roi(i_src,j_src,*i_dest,*j_dest); @@ -91,7 +91,7 @@ void case_destination(pile **tableau,int N,int i_src,int j_src, int *i_dest,int } } -int pions(pile **tableau,int i_src,int j_src,int i_dest,int j_dest,int tour) +int pions(pile **tableau,int N,int i_src,int j_src,int i_dest,int j_dest,int tour) { int k=0; if ("BN"[tour%2] == 'N'){ @@ -99,8 +99,13 @@ int pions(pile **tableau,int i_src,int j_src,int i_dest,int j_dest,int tour) } else { k=-1; } - if (nb_de_pion(tableau[i_dest][j_dest],"BN"[tour%2+1])==0 && i_dest==i_src+k && j_dest==j_src){ - return 1; + if (nb_de_pion(tableau[i_dest][j_dest],"BN"[tour%2+1])==0 && j_dest==j_src){ + if (i_dest==i_src+k) + return 1; + if (i_dest==i_src+k+k && longueur_pile(tableau[i_src+k][j_src])==0){ + if (k<0 && i_src==N-2) return 1; + else if (k>0 && i_src==2) return 1; + } } else if (i_dest==i_src+k && (j_dest==j_src+1 || j_dest==j_src-1)){ return 1; } diff --git a/src/deplacement.h b/src/deplacement.h index 953bf50e45fc28f3ab142a9b2e0ea608c7ee7f82..2e021c47e9e479ccf6c407ae624cd6fc7d692843 100644 --- a/src/deplacement.h +++ b/src/deplacement.h @@ -30,7 +30,7 @@ void case_destination(pile **tableau,int N,int i_src,int j_src,int *i_dest,int * * @assign * @ensure : verifie que le déplacement est valide pour un pion */ -int pions(pile **tableau, int i_src,int j_src,int i_dest,int j_dest, int tour); +int pions(pile **tableau,int N, int i_src,int j_src,int i_dest,int j_dest, int tour); /* * @require diff --git a/stackchess b/stackchess index d5d40f291292aa9666dbdd2d91ea6ff9493a81c1..825ab593c4df81977e5f419fcd24b960f4b53b7b 100755 Binary files a/stackchess and b/stackchess differ