<button id="clear-rack" class="minibutton" data-l10n="text-content">Put back all the tiles of your rack in the bag</button>
<button id="show-rack" class="minibutton" data-l10n="text-content">Show my rack to other players</button>
<button id="check-spelling" class="minibutton" data-l10n="text-content" style="display:none">Check spelling for new words</button>
+ <button id="score-words" class="minibutton" data-l10n="text-content">Score new words</button>
<p id="info-spell-checking" style="display:none;"><span data-l0n="text-content">Spell checking is based on:</span> <a rel="noopener noreferrer" target="_blank" href="http://aspell.net">Aspell</a></p>
</div>
</body>
}
}
+ function scoreWords() {
+ let totalScore = 0;
+
+ const newWords = searchNewWords();
+ for (const k of Object.keys(newWords)) {
+ let wordFactor = 1;
+ let wordScore = 0;
+
+ const word = newWords[k];
+ for (let l = 0; l < word.letters.length; l++) {
+ const index = ((word.row + (l * word.incRow)) * 15) + word.col + (l * word.incCol);
+
+ /* Letter score */
+ const tilePlaceholder = boardCells[index].getElementsByClassName("tile-placeholder")[0];
+ const tile = tilePlaceholder.getElementsByClassName("tile")[0];
+ const letterScore = tile.lastChild.textContent;
+ let letterFactor = 1;
+
+ /* Is a freshly played letter? */
+ if (currentTilePlayed[index] == word.letters[l]) {
+ /* Letter factor */
+ if (boardCells[index].classList.contains("special-cell-doubleLetter")) {
+ letterFactor = 2;
+ } else if (boardCells[index].classList.contains("special-cell-tripleLetter")) {
+ letterFactor = 3;
+ }
+
+ /* Word factor */
+ if (boardCells[index].classList.contains("special-cell-doubleWord")) {
+ wordFactor *= 2;
+ } else if (boardCells[index].classList.contains("special-cell-tripleWord")) {
+ wordFactor *= 3;
+ }
+
+ }
+
+ wordScore += letterScore * letterFactor;
+ }
+
+ totalScore += wordScore * wordFactor;
+ }
+
+ /* Check for trivabble */
+ let number = 0;
+ for (const i of Object.keys(currentTilePlayed)) {
+ number++;
+ }
+ if (number == 7) {
+ totalScore += 50;
+ }
+
+ /* Confirm score */
+ myConfirm(
+ _("Do you want to add score to active player?") + " " + totalScore,
+ function () {
+ /* Add score to active player */
+ }
+ );
+ }
+
function triggerLaser(cell) {
if (!cell) {
return;
document.getElementById("clear-rack").onclick = clearRack;
document.getElementById("show-rack").onclick = showRack;
document.getElementById("check-spelling").onclick = checkSpellingClicked;
+ document.getElementById("score-words").onclick = scoreWords;
helpClear.onclick = clearGame;
document.getElementById("btn-settings").onclick = showSettings;