diff --git a/src/Safari/PlateauSafari.cpp b/src/Safari/PlateauSafari.cpp index 3184c66..09c2327 100644 --- a/src/Safari/PlateauSafari.cpp +++ b/src/Safari/PlateauSafari.cpp @@ -156,23 +156,28 @@ bool PlateauSafari::deplacementValideCoor(const int x1, const int y1, Position pos1 = barriere->getPos(); Position pos2 = barriere->getPos2(); + /* Conditions si vrai = bloqués */ // Gauche vers droite - const bool gvd = std::max(pos1.first, pos2.first) >= std::max(x1, x2); + const bool gvd = + y1 == y2 && x1 > x2 && x2 >= std::max(pos1.first, pos2.first); // Droite vers gauche - const bool dvg = std::min(pos1.first, pos2.first) <= std::min(x1, x2); + const bool dvg = + y1 == y2 && x1 < x2 && x2 <= std::min(pos1.first, pos2.first); // Haut vers bas / Descendre - const bool hvb = std::max(pos1.second, pos2.second) >= std::max(y1, y2); + const bool hvb = + x1 == x2 && y1 < y2 && y2 >= std::max(pos1.second, pos2.second); // Bas vers haut / Monter - const bool bvh = std::min(pos1.second, pos2.second) <= std::min(y1, y2); + const bool bvh = + x1 == x2 && y1 > y2 && y2 <= std::min(pos1.second, pos2.second); if (d) { - std::cout << std::boolalpha << "barriere" << pos1.first << "," - << pos1.second << "|" << pos2.first << "," << pos2.second - << " et pieces" << x1 << "," << y1 << "|" << x2 << "," << y2 - << "=> " << gvd << " " << dvg << " " << hvb << " " << bvh << " " + std::cout << std::boolalpha << "barriere " << pos1.first << "," + << pos1.second << " | " << pos2.first << "," << pos2.second + << " et pieces " << x1 << "," << y1 << " | " << x2 << "," << y2 + << " => " << gvd << " " << dvg << " " << hvb << " " << bvh << std::endl; } - if (gvd && dvg && hvb && bvh) { + if (gvd || dvg || hvb || bvh) { return false; } }