This commit is contained in:
Mylloon 2024-01-08 02:01:16 +01:00
parent 8de0dc19dd
commit e7ffed3005
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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 << " "
<< " => " << gvd << " " << dvg << " " << hvb << " " << bvh
<< std::endl;
}
if (gvd && dvg && hvb && bvh) {
if (gvd || dvg || hvb || bvh) {
return false;
}
}