bonuspunkt wenn alles richtig

GUI
eric 2025-08-14 19:48:22 +02:00
parent e7c0f6522d
commit 9c9690f90e
2 changed files with 10 additions and 3 deletions

View File

@ -177,13 +177,17 @@
currentGuesses.getOrDefault(gameId, Collections.emptyMap());
// Scoring: +3 falls Auswahl Owner enthält, -1 pro falschem Tipp
// Bonus: +1, wenn kein falscher Tipp in der Runde (fehlerfrei)
for (var e : byUser.entrySet()) {
String user = e.getKey();
List<String> guesses = e.getValue();
if (guesses == null) continue;
boolean correct = owner != null && guesses.contains(owner);
int wrong = guesses.size() - (correct ? 1 : 0);
int delta = (correct ? 3 : 0) - wrong;
//int delta = (correct ? 3 : 0) - wrong;
int bonus = (wrong == 0) ? 1 : 0; // fehlerfrei-Bonus
int delta = (correct ? 3 : 0) - wrong + bonus;
if (delta != 0) game.scores().merge(user, delta, Integer::sum);
}

View File

@ -388,11 +388,14 @@ function handleRoundResult({ scores, guesses, owner }) {
const list = Array.isArray(g) ? g : (typeof g === "string" ? [g] : []);
const correct = list.includes(owner);
const wrongCount = list.length - (correct ? 1 : 0);
const delta = (correct ? 3 : 0) - wrongCount;
//const delta = (correct ? 3 : 0) - wrongCount;
const bonus = wrongCount === 0 ? 1 : 0; // fehlerfrei-Bonus
const delta = (correct ? 3 : 0) - wrongCount + bonus;
const icon = correct ? "✅" : "❌";
const picks = list.length ? list.join(", ") : "—";
const p = document.createElement("p");
p.textContent = `${icon} ${user} hat auf ${picks} getippt${correct ? " (richtig!)" : ""} [${delta >= 0 ? "+" : ""}${delta}]`;
//p.textContent = `${icon} ${user} hat auf ${picks} getippt${correct ? " (richtig!)" : ""} [${delta >= 0 ? "+" : ""}${delta}]`;
p.textContent = `${icon} ${user} hat auf ${picks} getippt${correct ? " (richtig!)" : ""}${bonus ? " (+1 Bonus)" : ""} [${delta >= 0 ? "+" : ""}${delta}]`;
resultP.appendChild(p);
});