diff --git a/scoreboard/controllers/score.js b/scoreboard/controllers/score.js index 1bdefe0..5a6ee10 100644 --- a/scoreboard/controllers/score.js +++ b/scoreboard/controllers/score.js @@ -17,16 +17,6 @@ let teamB = { let sideswitch = false; // Attribute to switch sides after halftime 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 function setEnabled(status) { enabled = status; @@ -52,6 +42,7 @@ function setScore(team, score) { } else if(team == "teamB") { 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) @@ -61,7 +52,7 @@ function alterScore(team, dir) { teamA.score++; console.log("teamA inc"); } - else if(dir == "dec") { + else if(dir == "dec" && teamA.score > 0) { // Kein negativer Spielstand teamA.score--; console.log("teamA dec"); } @@ -70,7 +61,7 @@ function alterScore(team, dir) { teamB.score++; console.log("teamB inc"); } - else if(dir == "dec") { + else if(dir == "dec" && teamB.score > 0) { // Kein negativer Spielstand teamB.score--; console.log("teamB dec"); } diff --git a/scoreboard/controllers/timer.js b/scoreboard/controllers/timer.js index f029377..4e8a02c 100644 --- a/scoreboard/controllers/timer.js +++ b/scoreboard/controllers/timer.js @@ -7,15 +7,6 @@ let durationLeft = moment.duration(7, 'minutes'); // durationLeft after the t 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 function start() { 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 } -// 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) { console.log("Timer Zurückgesetzt"); 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 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(); } else { 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 = { - duration, durationLeft, isPaused, start, pause, reset, end, print, incDec, getValues + start, pause, reset, end, print, incDec, getValues } \ No newline at end of file diff --git a/scoreboard/views/admin.hbs b/scoreboard/views/admin.hbs index 735a685..e16cf42 100644 --- a/scoreboard/views/admin.hbs +++ b/scoreboard/views/admin.hbs @@ -298,7 +298,7 @@

Achtung, eine Fehlbedienung kann unerwünschtes Verhalten hervorrufen.

- +
@@ -306,7 +306,7 @@
- +


@@ -316,7 +316,7 @@

Team Datenbank:

- +