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 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 :
* - 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 */
* - Barrière horizontal/vertical
* - Barrière sur la ligne/colonne
* - 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
const bool gvd = y1 == y2 && x1 < x2 && y1 == pos1.second &&
pos1.second == pos2.second &&
const bool gvd = deplacementHorizontal && barriereVertical && versDroite &&
// Départ avant barrière et arrivé après
x1 < std::max(pos1.first, pos2.first) &&
x2 >= std::max(pos1.first, pos2.first);
// Droite vers gauche
const bool dvg = y1 == y2 && x1 > x2 && y1 == pos1.second &&
pos1.second == pos2.second &&
const bool dvg = deplacementHorizontal && barriereVertical && versGauche &&
// Départ avant barrière et arrivé après
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 && x1 == pos1.first &&
pos1.first == pos2.first &&
const bool hvb = deplacementVertical && barriereHorizontal && descendre &&
// Départ avant barrière et arrivé après
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 && x1 == pos1.first &&
pos1.first == pos2.first &&
const bool bvh = deplacementVertical && barriereHorizontal && monter &&
// Départ avant barrière et arrivé après
y1 > std::min(pos1.second, pos2.second) &&
y2 <= std::min(pos1.second, pos2.second);