use a local variable to store player's name
authorLaurent Mazet <mazet@softndesign.org>
Tue, 24 Nov 2020 12:21:39 +0000 (13:21 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Tue, 24 Nov 2020 12:21:39 +0000 (13:21 +0100)
public/trivabble.js

index 3ee40adcca17ed68b200d684f69000383327d973..3ca0cfd36a2a3ba8797b4ee98d36222b5f8fb794 100644 (file)
             totalScore += getSetting("PREMIUM_SEVEN_TILES");
         }
 
-        /* Ѕcore player who pressed the button */
-        if (!getSetting("SCORE_LAST_PLAYER")) {
-            lastPlayer = getSetting("PlayerName");
-        }
+        /* Ѕcore last player or the one who pressed the button */
+        const playerName = getSetting("SCORE_LAST_PLAYER") ? lastPlayer : getSetting("PlayerName");
 
         myChoice(
             format(_("{0} points will be added to:"), totalScore), {
                     score: parseInt(getScoreCell(name).textContent) + totalScore
                 }]);
             },
-            lastPlayer || currentPlayer || getSetting("PlayerName")
+            playerName || lastPlayer || currentPlayer || getSetting("PlayerName")
         );
     }