Bugfixes: Timer-Zuschlag, Debugfenster-Schalter, Score-Untergrenze
timerIncDec beendete den Timer auch beim Hinzufuegen von Zeit: die Pruefung verglich den Betrag des Werts mit der Restzeit, ohne die Richtung zu beachten. Bei 5s Restzeit fuehrte "+10s" damit zum Spielende statt zu 15s. Die Pruefung gilt jetzt nur noch fuer negative Werte. Beim Verringern unter 0 wird die Restzeit zusaetzlich sauber auf 00:00 gesetzt, sonst blieb sie stehen und der Timer war trotz "ENDE" auf dem Monitor wieder startbar. Im Debugfenster zeigten alle drei Label auf scoreSwitchEnable. Ein Klick auf den Text "Teamanzeige spiegeln" oder "Splashscreen anzeigen" blendete damit das Scoreboard aus. Jede Beschriftung zeigt jetzt auf ihren eigenen Schalter. scoreSetScore sendet den neuen Stand jetzt wie alterScore und clearScore an die Monitore; der Endpunkt wird vom Panel nicht verwendet, ist aber dokumentiert. alterScore laesst den Spielstand nicht mehr unter 0 laufen. Die toten Funktionsprototypen in timer.js und score.js sind entfernt: sie wurden durch Hoisting ohnehin ueberschrieben und listeten toggleReferenceMirrored und print schon nicht mehr auf. Ebenso die Wert-Snapshots duration, durationLeft und isPaused aus module.exports, die dauerhaft die Startwerte lieferten. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
a1cea9c37d
commit
6f4c63aa6e
3 changed files with 15 additions and 27 deletions
|
|
@ -17,16 +17,6 @@ let teamB = {
|
||||||
let sideswitch = false; // Attribute to switch sides after halftime
|
let sideswitch = false; // Attribute to switch sides after halftime
|
||||||
let referenceMirrored = false; // If sitting behind the scoreboard, switch sides for admin board
|
let referenceMirrored = false; // If sitting behind the scoreboard, switch sides for admin board
|
||||||
|
|
||||||
// Funktionsübersicht (Prototypen ohne Implementierung — nur zur Übersicht)
|
|
||||||
function setEnabled(status) {};
|
|
||||||
function configTeam(team, name, name2, isSpielgemeinschaft) {};
|
|
||||||
function setScore(team, score) {};
|
|
||||||
function alterScore(team, dir) {};
|
|
||||||
function clearScore() {};
|
|
||||||
function toggleSideswitch() {};
|
|
||||||
function getEnabled() {};
|
|
||||||
function getValues() {};
|
|
||||||
|
|
||||||
// Enable or disable the scoreboard
|
// Enable or disable the scoreboard
|
||||||
function setEnabled(status) {
|
function setEnabled(status) {
|
||||||
enabled = status;
|
enabled = status;
|
||||||
|
|
@ -52,6 +42,7 @@ function setScore(team, score) {
|
||||||
} else if(team == "teamB") {
|
} else if(team == "teamB") {
|
||||||
teamB.score = score;
|
teamB.score = score;
|
||||||
}
|
}
|
||||||
|
io.sockets.emit('score', print()); // Wie alterScore und clearScore den Monitor mitziehen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ändert den Score eines Teams um 1 — Richtung "inc" (erhöhen) oder "dec" (verringern)
|
// Ändert den Score eines Teams um 1 — Richtung "inc" (erhöhen) oder "dec" (verringern)
|
||||||
|
|
@ -61,7 +52,7 @@ function alterScore(team, dir) {
|
||||||
teamA.score++;
|
teamA.score++;
|
||||||
console.log("teamA inc");
|
console.log("teamA inc");
|
||||||
}
|
}
|
||||||
else if(dir == "dec") {
|
else if(dir == "dec" && teamA.score > 0) { // Kein negativer Spielstand
|
||||||
teamA.score--;
|
teamA.score--;
|
||||||
console.log("teamA dec");
|
console.log("teamA dec");
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +61,7 @@ function alterScore(team, dir) {
|
||||||
teamB.score++;
|
teamB.score++;
|
||||||
console.log("teamB inc");
|
console.log("teamB inc");
|
||||||
}
|
}
|
||||||
else if(dir == "dec") {
|
else if(dir == "dec" && teamB.score > 0) { // Kein negativer Spielstand
|
||||||
teamB.score--;
|
teamB.score--;
|
||||||
console.log("teamB dec");
|
console.log("teamB dec");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,6 @@ let durationLeft = moment.duration(7, 'minutes'); // durationLeft after the t
|
||||||
|
|
||||||
let isPaused = true; // Status of the timer
|
let isPaused = true; // Status of the timer
|
||||||
|
|
||||||
// Function prototypes
|
|
||||||
function start() {};
|
|
||||||
function pause() {};
|
|
||||||
function reset() {};
|
|
||||||
function end() {};
|
|
||||||
function print() {};
|
|
||||||
function incDec() {};
|
|
||||||
function getValues() {};
|
|
||||||
|
|
||||||
// Start timer not paused and not already finished
|
// Start timer not paused and not already finished
|
||||||
function start() {
|
function start() {
|
||||||
if(isPaused == true && durationLeft.asSeconds() != 0) { // Only allow start if timer ist currently paused and durationLeft is not 0 seconds
|
if(isPaused == true && durationLeft.asSeconds() != 0) { // Only allow start if timer ist currently paused and durationLeft is not 0 seconds
|
||||||
|
|
@ -45,7 +36,9 @@ function pause() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer to passed value, and send durationLeft to all clients
|
// Reset timer to passed value, and send durationLeft to all clients.
|
||||||
|
// Ein laufender Timer wird bewusst nicht angehalten, sondern zaehlt von der
|
||||||
|
// neuen Zeit weiter herunter.
|
||||||
function reset(newDuration) {
|
function reset(newDuration) {
|
||||||
console.log("Timer Zurückgesetzt");
|
console.log("Timer Zurückgesetzt");
|
||||||
duration = moment.duration(newDuration, 'seconds').clone(); // Set initial duration to received duration in seconds
|
duration = moment.duration(newDuration, 'seconds').clone(); // Set initial duration to received duration in seconds
|
||||||
|
|
@ -69,7 +62,8 @@ function print() {
|
||||||
|
|
||||||
// Increase or decrease the timer depending on the passed value in seconds
|
// Increase or decrease the timer depending on the passed value in seconds
|
||||||
function incDec(value) {
|
function incDec(value) {
|
||||||
if(Math.abs(value) >= durationLeft.asSeconds()) { // If abs from passed value is greater than seconds left on timer, end timer
|
if(value < 0 && Math.abs(value) >= durationLeft.asSeconds()) { // Nur beim Verringern: faellt die Restzeit auf 0 oder darunter, Timer beenden
|
||||||
|
durationLeft = moment.duration(0, 'seconds'); // Restzeit sauber auf 00:00, sonst bliebe der Timer trotz "ENDE" startbar
|
||||||
end();
|
end();
|
||||||
} else {
|
} else {
|
||||||
durationLeft.add(value, 'second');
|
durationLeft.add(value, 'second');
|
||||||
|
|
@ -87,6 +81,9 @@ function getValues() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// duration, durationLeft und isPaused werden bewusst nicht exportiert: Exporte
|
||||||
|
// werden beim Laden des Moduls einmal ausgewertet und wuerden dauerhaft die
|
||||||
|
// Startwerte liefern. Der aktuelle Stand kommt ueber getValues().
|
||||||
module.exports = {
|
module.exports = {
|
||||||
duration, durationLeft, isPaused, start, pause, reset, end, print, incDec, getValues
|
start, pause, reset, end, print, incDec, getValues
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +298,7 @@
|
||||||
<p>Achtung, eine Fehlbedienung kann unerwünschtes Verhalten hervorrufen.</p>
|
<p>Achtung, eine Fehlbedienung kann unerwünschtes Verhalten hervorrufen.</p>
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input class="form-check-input" onclick="scoreToggleReferenceMirrored()" type="checkbox" role="switch" id="scoreSwitchReferenceMirrored">
|
<input class="form-check-input" onclick="scoreToggleReferenceMirrored()" type="checkbox" role="switch" id="scoreSwitchReferenceMirrored">
|
||||||
<label class="form-check-label" for="scoreSwitchEnable">Teamanzeige im Adminpanel spiegeln?</label>
|
<label class="form-check-label" for="scoreSwitchReferenceMirrored">Teamanzeige im Adminpanel spiegeln?</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input class="form-check-input" onclick="scoreToggle()" type="checkbox" role="switch" id="scoreSwitchEnable">
|
<input class="form-check-input" onclick="scoreToggle()" type="checkbox" role="switch" id="scoreSwitchEnable">
|
||||||
|
|
@ -306,7 +306,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input class="form-check-input" onclick="etcToggleSplashscreen()" type="checkbox" role="switch" id="etcSwitchEnable">
|
<input class="form-check-input" onclick="etcToggleSplashscreen()" type="checkbox" role="switch" id="etcSwitchEnable">
|
||||||
<label class="form-check-label" for="scoreSwitchEnable">SG-Arheilgen Splashscreen anzeigen?</label>
|
<label class="form-check-label" for="etcSwitchEnable">SG-Arheilgen Splashscreen anzeigen?</label>
|
||||||
</div>
|
</div>
|
||||||
<button class="mb-2 btn btn-lg btn-warning" onclick="refreshMonitor()"><i class="fa-solid fa-rotate"></i> Monitor neu laden</button> <br>
|
<button class="mb-2 btn btn-lg btn-warning" onclick="refreshMonitor()"><i class="fa-solid fa-rotate"></i> Monitor neu laden</button> <br>
|
||||||
<button class="mb-2 btn btn-lg btn-success" onclick="openBrowser()"><i class="fa-solid fa-rocket"></i> Browser öffnen</button> <br>
|
<button class="mb-2 btn btn-lg btn-success" onclick="openBrowser()"><i class="fa-solid fa-rocket"></i> Browser öffnen</button> <br>
|
||||||
|
|
@ -316,7 +316,7 @@
|
||||||
<p class="fw-bold">Team Datenbank:</p>
|
<p class="fw-bold">Team Datenbank:</p>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<span class="input-group-text"><i class="fa-solid fa-user-plus"></i></span>
|
<span class="input-group-text"><i class="fa-solid fa-user-plus"></i></span>
|
||||||
<input type="text" class="form-control" id="dbTeamToAdd" aria-describedby="teamBnameHelp">
|
<input type="text" class="form-control" id="dbTeamToAdd">
|
||||||
<button class="btn btn-outline-success" type="button" onclick="dbAddTeam()"><i class="fa-solid fa-plus"></i></button>
|
<button class="btn btn-outline-success" type="button" onclick="dbAddTeam()"><i class="fa-solid fa-plus"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue