Skip to content

Commit

Permalink
Fix scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Mar 24, 2024
1 parent b7654ba commit d6cc801
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ <h4 id="yesterday-or-random" class="answers">Yesterday's answers</h4>
localStorage.setItem("foundwords", JSON.stringify(foundlist));
}

function is_pangram(word) {
function is_pangram(word, wordletters) {
var pangram = true;

for (var letter of letters) {
for (var letter of wordletters) {
if (!word.includes(letter.at(-1))) {
pangram = false;
}
Expand All @@ -564,12 +564,12 @@ <h4 id="yesterday-or-random" class="answers">Yesterday's answers</h4>
return pangram;
}

function get_points(word) {
function get_points(word, wordletters) {
if (word.length == 4) {
return 1;
}

if (is_pangram(word)) {
if (is_pangram(word, wordletters)) {
return word.length + 7;
} else {
return word.length;
Expand All @@ -581,12 +581,12 @@ <h4 id="yesterday-or-random" class="answers">Yesterday's answers</h4>
save_word();
}

if (is_pangram(guess)) {
if (is_pangram(guess, letters)) {
document.getElementById("no-message").style.display = "none";
document.getElementById("pangram").style.display = "inline";
}

points = points + get_points(guess);
points = points + get_points(guess, letters);
}

function found_word() {
Expand Down Expand Up @@ -807,7 +807,7 @@ <h4 id="yesterday-or-random" class="answers">Yesterday's answers</h4>
return {
wordlist: puzzlewordlist,
words: puzzlewordlist.length,
total: puzzlewordlist.map(get_points).reduce((a, b) => a + b, 0),
total: puzzlewordlist.map(x => get_points(x, puzzle.slice(0, 6))).reduce((a, b) => a + b, 0),
letters: puzzle.slice(0, 6),
center: puzzle.at(6)
}
Expand Down

0 comments on commit d6cc801

Please sign in to comment.