P3.5 phase (OBSERVE par defaut) : tests + test des reglages 0.6
- Vanilla refuse deja le passage dans un bloc : le controle compte les positions refusees dont la boite declaree chevauche un bloc solide alors que la derniere position acceptee est libre (5 en 10 s). - Tests : PhaseP06Test (8), Reglages06Test (cles 0.6 = champs GardeConfig, memes defauts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
544f11dfa5
révision
fad2bf0437
3 fichiers modifiés
+126
-1
Aucun fichier ne correspond à votre recherche
@@ -603,7 +603,7 @@ public final class GardeSpec {
|
||||
c.towerSerie = TOWER_SERIE.get();
|
||||
c.completionParSecondeMax = COMPLETION_PAR_S.get();
|
||||
c.completionRafaleMax = COMPLETION_RAFALE.get();
|
||||
// 0.6 : champs du même nom dans GardeConfig (vérifié par Garde06Test).
|
||||
// 0.6 : champs du même nom dans GardeConfig (vérifié par Reglages06Test).
|
||||
for (java.util.Map.Entry<String, ModConfigSpec.ConfigValue<?>> e : V06.entrySet()) {
|
||||
try {
|
||||
java.lang.reflect.Field f = GardeConfig.class.getField(e.getKey());
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.gastinelgarde;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.gastinelgarde.core.GardeConfig;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** 0.6 : chaque réglage des sections [inventaire], [scaffold], [blink], [phase] a son champ dans GardeConfig. */
|
||||
class Reglages06Test {
|
||||
|
||||
@Test
|
||||
void chaqueCleA0nChampDuMemeNomEtLeMemeDefaut() throws Exception {
|
||||
String src = Files.readString(Path.of(System.getProperty("gastinelgarde.projet", "."), "src/main/java/com/gastinelgarde/GardeSpec.java"));
|
||||
Matcher m = Pattern.compile("V06\\.put\\(\"(\\w+)\".*?defineInRange\\(\"(\\w+)\", ([0-9.]+),", Pattern.DOTALL).matcher(src);
|
||||
GardeConfig c = new GardeConfig();
|
||||
int n = 0;
|
||||
while (m.find()) {
|
||||
assertEquals(m.group(1), m.group(2), "cle et champ");
|
||||
java.lang.reflect.Field f = GardeConfig.class.getField(m.group(1));
|
||||
double defaut = f.getType() == int.class ? f.getInt(c) : f.getDouble(c);
|
||||
assertEquals(Double.parseDouble(m.group(3)), defaut, 1e-9, m.group(1));
|
||||
n++;
|
||||
}
|
||||
assertTrue(n >= 19, "reglages trouves : " + n);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** 0.6, P3.5 : phase (positions refusées par vanilla dans un bloc solide, en série). */
|
||||
class PhaseP06Test {
|
||||
|
||||
private final GardeConfig cfg = new GardeConfig();
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
|
||||
private int refus(Moteur m, long nowMs, EtatJoueur e, boolean dansBloc) {
|
||||
int n = 0;
|
||||
for (Verdict v : m.refusPhase(joueur, nowMs, e, dansBloc, 0.5)) if (v.controle() == Controle.PHASE && v.points() > 0) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
@Test
|
||||
void observeParDefaut() {
|
||||
assertEquals(Mode.OBSERVE, cfg.mode(Controle.PHASE));
|
||||
assertEquals(Controle.PHASE, Controle.parse("phase"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void porteQuiSeFermeQuelquesRefusNonVu() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
int n = 0;
|
||||
for (int i = 0; i < 4; i++) n += refus(m, 1000 + i * 500L, EtatJoueur.normal(), true);
|
||||
assertEquals(0, n);
|
||||
}
|
||||
|
||||
@Test
|
||||
void refusHorsBlocNonComptes() {
|
||||
// « moved too quickly » à cause du lag : refus, mais la position déclarée est libre.
|
||||
Moteur m = new Moteur(cfg);
|
||||
int n = 0;
|
||||
for (int i = 0; i < 50; i++) n += refus(m, 1000 + i * 100L, EtatJoueur.normal(), false);
|
||||
assertEquals(0, n);
|
||||
}
|
||||
|
||||
@Test
|
||||
void refusEspacesNonVus() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
int n = 0;
|
||||
for (int i = 0; i < 20; i++) n += refus(m, i * 15_000L, EtatJoueur.normal(), true);
|
||||
assertEquals(0, n);
|
||||
}
|
||||
|
||||
@Test
|
||||
void clientDePhaseVu() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
int n = 0;
|
||||
for (int i = 0; i < 20; i++) n += refus(m, 1000 + i * 100L, EtatJoueur.normal(), true);
|
||||
assertEquals(20 - cfg.phaseSerieMin + 1, n);
|
||||
}
|
||||
|
||||
@Test
|
||||
void enforceMonteAuPalier() {
|
||||
cfg.mode(Controle.PHASE, Mode.ENFORCE);
|
||||
Moteur m = new Moteur(cfg);
|
||||
boolean setback = false;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
for (Verdict v : m.refusPhase(joueur, 1000 + i * 100L, EtatJoueur.normal(), true, 1)) {
|
||||
if (v.applicable().ordinal() >= Sanction.SETBACK.ordinal()) setback = true;
|
||||
}
|
||||
}
|
||||
assertTrue(setback);
|
||||
}
|
||||
|
||||
@Test
|
||||
void exemptions() {
|
||||
EtatJoueur[] etats = {EtatJoueur.builder().creatif(true).build(), EtatJoueur.builder().spectateur(true).build(),
|
||||
EtatJoueur.builder().pocheContraption(true).build(), EtatJoueur.builder().elytres(true).build(),
|
||||
EtatJoueur.builder().enVehicule(true).build(), EtatJoueur.builder().ticksDepuisTeleport(5).build(),
|
||||
EtatJoueur.builder().ticksDepuisGel(5).build(), EtatJoueur.builder().tps(10).build()};
|
||||
for (EtatJoueur e : etats) {
|
||||
Moteur m = new Moteur(cfg);
|
||||
int n = 0;
|
||||
for (int i = 0; i < 20; i++) n += refus(m, 1000 + i * 100L, e, true);
|
||||
assertEquals(0, n, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void etatOublieALaDeconnexion() {
|
||||
Moteur m = new Moteur(cfg);
|
||||
for (int i = 0; i < 4; i++) refus(m, 1000 + i * 100L, EtatJoueur.normal(), true);
|
||||
m.retirer(joueur);
|
||||
assertEquals(0, refus(m, 1500, EtatJoueur.normal(), true));
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur