je vais me tuer

This commit is contained in:
Mylloon 2024-01-08 02:55:15 +01:00
parent 98fceab42c
commit 11a1f1ae14
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -156,31 +156,47 @@ bool PlateauSafari::deplacementValideCoor(const int x1, const int y1,
Position pos1 = barriere->getPos(); Position pos1 = barriere->getPos();
Position pos2 = barriere->getPos2(); Position pos2 = barriere->getPos2();
/* Conditions si vrai = bloqués /* Conditions si vrai = bloqués = une barrière est sur le chemin
* Ordre dans les vérifications : * Ordre dans les vérifications :
* - Horizontal/Vertical * - Horizontal/Vertical
* - Sens du déplacement * - Sens du déplacement
* - Barrière regardé bien sur la ligne/colonne (2 conditions) * - Barrière horizontal/vertical
* - Barrière pas derrière nous * - Barrière sur la ligne/colonne
* - Si la barrière nous bloque */ * - Départ avant la barrière
* - Arrivé après la barrière */
const bool deplacementVertical = x1 == x2;
const bool deplacementHorizontal = y1 == y2;
const bool versGauche = x1 > x2;
const bool versDroite = x1 < x2;
const bool monter = y1 > y2;
const bool descendre = y1 < y2;
const bool barriereVertical = pos1.second == pos2.second &&
// Bien positionnée
y1 == pos1.second;
const bool barriereHorizontal = pos1.first == pos2.first &&
// Bien positionnée
x1 == pos1.first;
// Gauche vers droite // Gauche vers droite
const bool gvd = y1 == y2 && x1 < x2 && y1 == pos1.second && const bool gvd = deplacementHorizontal && barriereVertical && versDroite &&
pos1.second == pos2.second && // Départ avant barrière et arrivé après
x1 < std::max(pos1.first, pos2.first) && x1 < std::max(pos1.first, pos2.first) &&
x2 >= std::max(pos1.first, pos2.first); x2 >= std::max(pos1.first, pos2.first);
// Droite vers gauche // Droite vers gauche
const bool dvg = y1 == y2 && x1 > x2 && y1 == pos1.second && const bool dvg = deplacementHorizontal && barriereVertical && versGauche &&
pos1.second == pos2.second && // Départ avant barrière et arrivé après
x1 > std::min(pos1.first, pos2.first) && x1 > std::min(pos1.first, pos2.first) &&
x2 <= std::min(pos1.first, pos2.first); x2 <= std::min(pos1.first, pos2.first);
// Haut vers bas / Descendre // Haut vers bas / Descendre
const bool hvb = x1 == x2 && y1 < y2 && x1 == pos1.first && const bool hvb = deplacementVertical && barriereHorizontal && descendre &&
pos1.first == pos2.first && // Départ avant barrière et arrivé après
y1 < std::max(pos1.second, pos2.second) && y1 < std::max(pos1.second, pos2.second) &&
y2 >= std::max(pos1.second, pos2.second); y2 >= std::max(pos1.second, pos2.second);
// Bas vers haut / Monter // Bas vers haut / Monter
const bool bvh = x1 == x2 && y1 > y2 && x1 == pos1.first && const bool bvh = deplacementVertical && barriereHorizontal && monter &&
pos1.first == pos2.first && // Départ avant barrière et arrivé après
y1 > std::min(pos1.second, pos2.second) && y1 > std::min(pos1.second, pos2.second) &&
y2 <= std::min(pos1.second, pos2.second); y2 <= std::min(pos1.second, pos2.second);