GastinelGarde 0.4.0 : score de suspicion, flottement du vol, motif de sanction corrige

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
gastineltetClaude Sonnet 5.5 a révisé 2026-10-23 15:52:27 +02:00
1 Parent 288087080f
révision c7b130ec1c
14 fichiers modifiés
+985 -2

Aucun fichier ne correspond à votre recherche

+29
Voir le fichier
@@ -143,6 +143,13 @@ public final class Garde {
Files.createDirectories(journal.getParent());
traces = new TraceFichier(jeu.resolve("gastinelgarde-traces"), GardeSpec.tracesJours(), GardeSpec.tracesTailleOctets());
tracesEnCours = GardeSpec.tracesActives();
// Historique de suspicion : même dossier de jeu que les traces et les journaux (voir HistoriqueSuspicion).
try {
MOTEUR.historique().ouvrir(jeu.resolve("gastinelgarde-suspicion").resolve("incidents.csv"),
System.currentTimeMillis(), CONFIG.suspicionHistoriqueJours);
} catch (IOException | RuntimeException e) {
GastinelGarde.LOGGER.warn("[GastinelGarde] historique de suspicion illisible, repart à vide : {}", e.toString());
}
} catch (IOException e) {
GastinelGarde.LOGGER.error("[GastinelGarde] Impossible d'ouvrir le dossier de traces", e);
traces = null;
@@ -524,9 +531,31 @@ public final class Garde {
}
if (v.notifier()) alerterOps(p, v);
}
reagirSuspicion(p);
return Verdict.pire(verdicts);
}
/**
* Score de suspicion (0.4.0) : journal dès « à surveiller », message aux ops dès « suspect ». À « suspect fort »,
* seulement une proposition de sanction à valider dans le Portail : le mod ne sanctionne jamais à partir du score.
*/
private static void reagirSuspicion(ServerPlayer p) {
Moteur.AlerteSuspicion a = MOTEUR.alerteSuspicion(p.getUUID(), System.currentTimeMillis());
if (a == null) return;
String nom = p.getGameProfile().getName();
ecrireJournal(String.format("SUSPICION %s (%s) score=%d niveau=%s incidents7j=%d contributions=[%s]",
nom, p.getUUID(), a.score(), a.niveau(), a.incidents(), a.controles()));
if (a.niveau().ordinal() < com.gastinelgarde.core.Suspicion.Niveau.SUSPECT.ordinal()) return;
String texte = a.niveau() == com.gastinelgarde.core.Suspicion.Niveau.SUSPECT_FORT
? String.format("[Garde] %s : suspect fort (score %d). Proposition de sanction suspect_2, à valider dans le Portail.",
nom, a.score())
: String.format("[Garde] %s : suspect (score %d, %d incident(s) sur 7 jours).", nom, a.score(), a.incidents());
Component msg = Component.literal(texte).withStyle(ChatFormatting.RED);
for (ServerPlayer op : p.server.getPlayerList().getPlayers()) {
if (op.hasPermissions(2) && alertesActivesPour(op.getUUID())) op.sendSystemMessage(msg);
}
}
private static void alerterOps(ServerPlayer cible, Verdict v) {
Component msg = Component.literal(String.format("[Garde] %s : %s VL=%.1f (%s, %s)",
cible.getGameProfile().getName(), v.controle().id(), v.vl(), v.mode(), v.applicable()))