From 98fceab42c1a31d2dc2d30e3bf58084a584ae94e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 Jan 2024 02:36:47 +0100 Subject: [PATCH] je comprends pas pk ca fonctionnnne pas --- src/Safari/PlateauSafari.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Safari/PlateauSafari.cpp b/src/Safari/PlateauSafari.cpp index 09c2327..7d3569b 100644 --- a/src/Safari/PlateauSafari.cpp +++ b/src/Safari/PlateauSafari.cpp @@ -156,19 +156,33 @@ bool PlateauSafari::deplacementValideCoor(const int x1, const int y1, Position pos1 = barriere->getPos(); Position pos2 = barriere->getPos2(); - /* Conditions si vrai = bloqués */ + /* Conditions si vrai = bloqués + * Ordre dans les vérifications : + * - Horizontal/Vertical + * - Sens du déplacement + * - Barrière regardé bien sur la ligne/colonne (2 conditions) + * - Barrière pas derrière nous + * - Si la barrière nous bloque */ // Gauche vers droite - const bool gvd = - y1 == y2 && x1 > x2 && x2 >= std::max(pos1.first, pos2.first); + const bool gvd = y1 == y2 && x1 < x2 && y1 == pos1.second && + pos1.second == pos2.second && + x1 < std::max(pos1.first, pos2.first) && + x2 >= std::max(pos1.first, pos2.first); // Droite vers gauche - const bool dvg = - y1 == y2 && x1 < x2 && x2 <= std::min(pos1.first, pos2.first); + const bool dvg = y1 == y2 && x1 > x2 && y1 == pos1.second && + pos1.second == pos2.second && + x1 > std::min(pos1.first, pos2.first) && + x2 <= std::min(pos1.first, pos2.first); // Haut vers bas / Descendre - const bool hvb = - x1 == x2 && y1 < y2 && y2 >= std::max(pos1.second, pos2.second); + const bool hvb = x1 == x2 && y1 < y2 && x1 == pos1.first && + pos1.first == pos2.first && + y1 < std::max(pos1.second, pos2.second) && + y2 >= std::max(pos1.second, pos2.second); // Bas vers haut / Monter - const bool bvh = - x1 == x2 && y1 > y2 && y2 <= std::min(pos1.second, pos2.second); + const bool bvh = x1 == x2 && y1 > y2 && x1 == pos1.first && + pos1.first == pos2.first && + y1 > std::min(pos1.second, pos2.second) && + y2 <= std::min(pos1.second, pos2.second); if (d) { std::cout << std::boolalpha << "barriere " << pos1.first << ","