From 8de0dc19dd3c81e312904c87ba515b76f485b6a8 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 Jan 2024 01:43:56 +0100 Subject: [PATCH] debug --- src/Safari/PlateauSafari.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Safari/PlateauSafari.cpp b/src/Safari/PlateauSafari.cpp index dd8638f..3184c66 100644 --- a/src/Safari/PlateauSafari.cpp +++ b/src/Safari/PlateauSafari.cpp @@ -156,26 +156,23 @@ bool PlateauSafari::deplacementValideCoor(const int x1, const int y1, Position pos1 = barriere->getPos(); Position pos2 = barriere->getPos2(); + // Gauche vers droite + const bool gvd = std::max(pos1.first, pos2.first) >= std::max(x1, x2); + // Droite vers gauche + const bool dvg = std::min(pos1.first, pos2.first) <= std::min(x1, x2); + // Haut vers bas / Descendre + const bool hvb = std::max(pos1.second, pos2.second) >= std::max(y1, y2); + // Bas vers haut / Monter + const bool bvh = std::min(pos1.second, pos2.second) <= std::min(y1, y2); + if (d) { std::cout << std::boolalpha << "barriere" << pos1.first << "," << pos1.second << "|" << pos2.first << "," << pos2.second << " et pieces" << x1 << "," << y1 << "|" << x2 << "," << y2 - << "=> " - << (std::max(pos1.first, pos2.first) >= std::max(x1, x2)) << " " - << (std::min(pos1.first, pos2.first) <= std::min(x1, x2)) << " " - << (std::max(pos1.second, pos2.second) >= std::max(y1, y2)) - << " " - << (std::min(pos1.second, pos2.second) <= std::min(y1, y2)) - << " " << std::endl; + << "=> " << gvd << " " << dvg << " " << hvb << " " << bvh << " " + << std::endl; } - if ( // Gauche vers droite - std::max(pos1.first, pos2.first) >= std::max(x1, x2) - // Droite vers gauche - && std::min(pos1.first, pos2.first) <= std::min(x1, x2) - // Haut vers bas / Descendre - && std::max(pos1.second, pos2.second) >= std::max(y1, y2) - // Bas vers haut / Monter - && std::min(pos1.second, pos2.second) <= std::min(y1, y2)) { + if (gvd && dvg && hvb && bvh) { return false; } }