0.4.2 : vraies sanctions pour auto-totem et velocite, seuils propres

- bride ALERTE retiree en ENFORCE ; auto-totem : palier SETBACK ramene a ALERTE, expulsion appliquee
- velocite : SETBACK = retour en arriere (setback mouvement existant), expulsion
- seuils optionnels dans [nouveauxControles] : autoTotemSeuilSetback (0 = global), autoTotemSeuilExpulsion = 9,
  velociteSeuilSetback = 8, velociteSeuilExpulsion = 16 (0 = seuil global de [sanctions])
- version 0.4.2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
gastineltetClaude Opus 5.5 a révisé 2026-10-23 19:38:40 +02:00
1 Parent 26d610f79a
révision e87b8374ef
10 fichiers modifiés
+197 -14

Aucun fichier ne correspond à votre recherche

+13
Voir le fichier
@@ -120,6 +120,19 @@ class CablageTest {
// --- Setback (C2, C3) ---
@Test
void v042_setbackVelociteRameneLaPositionEtExpulsionAutoTotemDeconnecte() {
Moteur moteur = new Moteur(new GardeConfig());
FauxJoueur p = new FauxJoueur();
moteur.suivi(ID).memoriserPosition(10.5, 64.0, -3.5, 90f, 10f, MONDE);
Cablage.appliquerSanction(moteur, p, Sanction.SETBACK, List.of(verdict(Controle.VELOCITE, Sanction.SETBACK)));
assertEquals(List.of("annonce SETBACK", "teleport 10.5 64.0 -3.5 90 10", "journal Tricheur SETBACK (velocite)"),
p.actions);
Cablage.appliquerSanction(moteur, p, Sanction.EXPULSION, List.of(verdict(Controle.AUTO_TOTEM, Sanction.EXPULSION)));
assertEquals(1, p.compte("deconnexion"));
assertTrue(moteur.estExpulse(ID));
}
@Test
void C2_setbackVersLaPositionAuSolPuisRemiseAZeroDuVol() {
Moteur moteur = new Moteur(new GardeConfig());
+4 -4
Voir le fichier
@@ -316,9 +316,9 @@ class NouveauxControlesTest {
}
@Test
void velociteEtAutoTotemJamaisDeSanctionMemeEnEnforce() {
cfg.mode(Controle.VELOCITE, Mode.ENFORCE);
cfg.mode(Controle.AUTO_TOTEM, Mode.ENFORCE);
void velociteEtAutoTotemJamaisDeSanctionEnObserve() { // 0.4.2 : en ENFORCE, voir Sanctions042Test
cfg.mode(Controle.VELOCITE, Mode.OBSERVE);
cfg.mode(Controle.AUTO_TOTEM, Mode.OBSERVE);
boolean vu = false;
for (int k = 0; k < 40; k++) {
now += 50;
@@ -553,7 +553,7 @@ class NouveauxControlesTest {
for (Verdict v : moteur.totemEnMain(j, now, EtatJoueur.normal(), true)) {
vus++;
assertEquals(Mode.ENFORCE, v.mode());
assertTrue(v.applicable().ordinal() <= Sanction.ALERTE.ordinal(), "jamais setback ni expulsion");
assertTrue(v.applicable() != Sanction.SETBACK, "0.4.2 : auto-totem n'a pas de setback (expulsion possible)");
}
}
assertEquals(10, vus, "les detections continuent en ENFORCE");
+128
Voir le fichier
@@ -0,0 +1,128 @@
package com.gastinelgarde.core;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** 0.4.2 : vraies sanctions pour auto-totem et velocite, seuils propres a ces controles. */
class Sanctions042Test {
private GardeConfig cfg;
private Moteur moteur;
private final UUID j = UUID.randomUUID();
private long now;
@BeforeEach
void init() {
cfg = new GardeConfig();
moteur = new Moteur(cfg);
now = 1_000_000;
}
@Test
void seuilsParDefaut() {
assertEquals(9, cfg.autoTotemSeuilExpulsion, 1e-9);
assertEquals(8, cfg.velociteSeuilSetback, 1e-9);
assertEquals(16, cfg.velociteSeuilExpulsion, 1e-9);
}
@Test
void paliersVelocite() {
assertEquals(Sanction.ALERTE, Paliers.palier(7.9, cfg, Controle.VELOCITE));
assertEquals(Sanction.SETBACK, Paliers.palier(8, cfg, Controle.VELOCITE));
assertEquals(Sanction.SETBACK, Paliers.palier(15.9, cfg, Controle.VELOCITE));
assertEquals(Sanction.EXPULSION, Paliers.palier(16, cfg, Controle.VELOCITE));
}
@Test
void paliersAutoTotem() {
assertEquals(Sanction.EXPULSION, Paliers.palier(9, cfg, Controle.AUTO_TOTEM));
assertTrue(Paliers.palier(8.9, cfg, Controle.AUTO_TOTEM).ordinal() < Sanction.EXPULSION.ordinal());
}
@Test
void seuilsAZeroRetombentSurLesSeuilsGlobaux() {
cfg.velociteSeuilSetback = 0;
cfg.velociteSeuilExpulsion = 0;
cfg.autoTotemSeuilExpulsion = 0;
for (double vl : new double[] {3, 9, 12, 15, 25}) {
assertEquals(Paliers.palier(vl, cfg), Paliers.palier(vl, cfg, Controle.VELOCITE));
assertEquals(Paliers.palier(vl, cfg), Paliers.palier(vl, cfg, Controle.AUTO_TOTEM));
}
cfg.velociteSeuilSetback = 8;
assertEquals(Paliers.palier(9, cfg), Paliers.palier(9, cfg, Controle.VITESSE), "autres controles inchanges");
}
@Test
void sanctionMaxResteRespecte() {
cfg.sanctionMax = Sanction.SETBACK;
assertEquals(Sanction.SETBACK, Paliers.palier(50, cfg, Controle.VELOCITE));
}
private List<Verdict> totem() {
moteur.totemEclate(j, now, false);
now += 50;
return moteur.totemEnMain(j, now, EtatJoueur.normal(), true);
}
@Test
void autoTotemEnforceExpulseSansJamaisDeSetback() {
cfg.mode(Controle.AUTO_TOTEM, Mode.ENFORCE);
Sanction pire = Sanction.AUCUNE;
int detections = 0;
for (int k = 0; k < 6 && pire != Sanction.EXPULSION; k++) {
for (Verdict v : totem()) {
detections++;
assertTrue(v.applicable() != Sanction.SETBACK, "palier SETBACK ramene a ALERTE");
if (v.applicable().ordinal() > pire.ordinal()) pire = v.applicable();
}
now += 300; // detections rapprochees
}
assertEquals(Sanction.EXPULSION, pire);
assertTrue(detections <= 4, "expulsion a la 3e ou 4e detection rapprochee : " + detections);
}
@Test
void autoTotemEnObserveJamaisDeSanction() {
for (int k = 0; k < 10; k++) {
for (Verdict v : totem()) assertTrue(v.applicable().ordinal() <= Sanction.ALERTE.ordinal());
now += 300;
}
}
private Sanction recul() {
now += 2000;
moteur.reculApplique(j, now, 1, 0, 0.4, true);
Sanction pire = Sanction.AUCUNE;
for (int i = 0; i < 7; i++) {
now += 50;
for (Verdict v : moteur.mesureRecul(j, now, EtatJoueur.normal(), 0, 0, false, (x, z) -> false)) {
if (v.applicable().ordinal() > pire.ordinal()) pire = v.applicable();
}
}
return pire;
}
@Test
void velociteEnforceSetbackPuisExpulsion() {
cfg.mode(Controle.VELOCITE, Mode.ENFORCE);
cfg.setbacksAvantExpulsion = 0; // isole les seuils de velocite (C5 teste ailleurs)
boolean setback = false;
Sanction s = Sanction.AUCUNE;
for (int k = 0; k < 20 && s != Sanction.EXPULSION; k++) {
s = recul();
if (s == Sanction.SETBACK) setback = true;
}
assertTrue(setback, "retour en arriere avant l'expulsion");
assertEquals(Sanction.EXPULSION, s);
}
@Test
void velociteEnObserveJamaisDeSanction() {
for (int k = 0; k < 20; k++) assertTrue(recul().ordinal() <= Sanction.ALERTE.ordinal());
}
}