bonuspunkt wenn alles richtig
parent
e7c0f6522d
commit
9c9690f90e
|
|
@ -177,13 +177,17 @@
|
||||||
currentGuesses.getOrDefault(gameId, Collections.emptyMap());
|
currentGuesses.getOrDefault(gameId, Collections.emptyMap());
|
||||||
|
|
||||||
// Scoring: +3 falls Auswahl Owner enthält, -1 pro falschem Tipp
|
// 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()) {
|
for (var e : byUser.entrySet()) {
|
||||||
String user = e.getKey();
|
String user = e.getKey();
|
||||||
List<String> guesses = e.getValue();
|
List<String> guesses = e.getValue();
|
||||||
if (guesses == null) continue;
|
if (guesses == null) continue;
|
||||||
boolean correct = owner != null && guesses.contains(owner);
|
boolean correct = owner != null && guesses.contains(owner);
|
||||||
int wrong = guesses.size() - (correct ? 1 : 0);
|
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);
|
if (delta != 0) game.scores().merge(user, delta, Integer::sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -388,11 +388,14 @@ function handleRoundResult({ scores, guesses, owner }) {
|
||||||
const list = Array.isArray(g) ? g : (typeof g === "string" ? [g] : []);
|
const list = Array.isArray(g) ? g : (typeof g === "string" ? [g] : []);
|
||||||
const correct = list.includes(owner);
|
const correct = list.includes(owner);
|
||||||
const wrongCount = list.length - (correct ? 1 : 0);
|
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 icon = correct ? "✅" : "❌";
|
||||||
const picks = list.length ? list.join(", ") : "—";
|
const picks = list.length ? list.join(", ") : "—";
|
||||||
const p = document.createElement("p");
|
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);
|
resultP.appendChild(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue