public override bool EstSimplementValide(Plateau plateau, Coords origine, Coords fin, ref int nbPrises) { if (!Plateau.EstDansLePlateau(fin)) { return(false); } Coords distance = fin - origine; Coords diag1 = EstBlanc ? new Coords(-1, 1) : new Coords(-1, -1); Coords diag2 = EstBlanc ? new Coords(1, 1) : new Coords(1, -1); if (distance.EstDiag()) { if (distance.Longueur() == 1) { if (distance != diag1 && distance != diag2) { return(false); } return(plateau.Get(fin) == null); } else if (distance.Longueur() == 2) { Piece tmp = plateau.Get(origine + distance / 2); if (tmp != null && tmp.EstBlanc != EstBlanc) { nbPrises++; return(plateau.Get(fin) == null); } } } return(false); }
public override bool EstSimplementValide(Plateau plateau, Coords origine, Coords fin, ref int nbPrises) { if (!Plateau.EstDansLePlateau(fin)) { return(false); } Coords deplacement = fin - origine; if (deplacement.EstDiag() && deplacement.Longueur() > 0) { deplacement = deplacement.GetVraiUnitaire(); bool dejaPrise = false; var tmp = origine; Piece tmpPiece = null; while (tmp.X != fin.X)//on se déplace en diagonale, pas besoin de tout comparer { tmp += deplacement; tmpPiece = plateau.Get(tmp); if (tmpPiece != null) { if (dejaPrise) { return(false); } else { dejaPrise = true; } if (tmpPiece.EstBlanc == EstBlanc) { return(false); } } } if (tmpPiece == null) { if (dejaPrise) { nbPrises++; } return(true); } } return(false); }