Skip to content

Commit

Permalink
practiceMode correctioino
Browse files Browse the repository at this point in the history
corrected a bug that where you pause activeWord twice on youtube/practice mode, the activeWord would be nulled leading to no possible input. Oopie.
  • Loading branch information
sabrina-aip committed Jan 15, 2024
1 parent 03a0090 commit a7b44d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions assets/scripts/practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function checkGuess() {
updatePlayer(playerLst, activePlayer)

// DEACTIVATE WORD
activeWord = null;
// activeWord = null;
activePlayer = null;


Expand All @@ -178,7 +178,7 @@ function updatePlayer(playerLst, activePlayer) {
lastActiveWord = activeWord;

// DEACTIVATE WORD
activeWord = null;
// activeWord = null;
activePlayer = null;
return;
}
Expand Down
28 changes: 16 additions & 12 deletions assets/scripts/youtube2.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function updateWord(){
function endGame(){
sessionStorage.setItem("submissionLst", submissionLst)
sessionStorage.setItem("correctSpellingLst",correctSpellingLst)
sessionStorage.setItem("level", level)
sessionStorage.setItem("level", "YouTube Challenge")

window.location.replace("practice_results.html");
}
Expand Down Expand Up @@ -118,6 +118,9 @@ function deleteLetter () {
}

function guessPreprocess() {
console.log(`lastActiveWord: ${lastActiveWord}`)
console.log(`activeWordd: ${activeWord}`)

if ((lastActiveWord != null) & (activeWord==null)) {
activeWord = lastActiveWord;
checkGuess()
Expand All @@ -141,16 +144,12 @@ function checkGuess() {
if (attemptStr.toLowerCase() == activeWord.toLowerCase()) {
submissionLst.push(`<td>${attemptStr}</td>`)
wordCounter += 1;

stopSound(activePlayer[1]);

updatePlayer(playerLst, activePlayer)

// DEACTIVATE WORD
activeWord = null;
// activeWord = null;
activePlayer = null;


// RECURSIVE CALL FOR NEW WORD
updateWord();
} else {
Expand All @@ -162,32 +161,37 @@ function checkGuess() {
attempt.value = attemptStr;
return
}

// update players to reflect their current status
function updatePlayer(playerLst, activePlayer) {
console.log("Running updatePlayer()")

if (activePlayer[0].classList.contains("clicked")) {
stopSound(activePlayer[1]);
activePlayer[0].classList.remove("clicked","fa-pause-circle");
activePlayer[0].classList.add("fa-play-circle");

lastActiveWord = activeWord;
console.log(`assigning lastActiveWord: ${lastActiveWord}`)

// DEACTIVATE WORD
activeWord = null;
// activeWord = null;
activePlayer = null;
return;
}

playerLst.forEach((player) => {
if ((!player[0].classList.contains("submitted")) & player[0] != activePlayer[0]) {
if (player[0] != activePlayer[0]) {
player[0].classList.remove("clicked", "fa-pause-circle");
stopSound(player[1]);
} else if ((!player[0].classList.contains("submitted")) & player[0] == activePlayer[0]) {
} else if (player[0] == activePlayer[0]) {
activePlayer[0].classList.add("clicked","fa-pause-circle");
activePlayer[1].play();
} else {
console.log("updatePlayer loophole triggered.")
}
})
return;


}

function resetPlayer(playerLst) {
Expand Down
4 changes: 2 additions & 2 deletions youtube.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ <h1 class="boxed" id="header-title"><span class="error">Speling</span> Bee</h1>
</div>
</div>
</body>
<script src="assets/scripts/wordLstGenerator.js"></script>
<script src="assets/scripts/youtube.js"></script>
<script src="assets/scripts/wordLstGenerator2.js"></script>
<script src="assets/scripts/youtube2.js"></script>
</html>

0 comments on commit a7b44d1

Please sign in to comment.