-
-
Save parzibyte/8fcb645d3f2f2dbb195cf1cf2a548c72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkGameStatus() { | |
if (this.playerWins()) { | |
Swal.fire("You win! The word was " + this.getUnhiddenWord()); | |
this.resetGame(); | |
} | |
if (this.playerLoses()) { | |
Swal.fire("You lose. The word was " + this.getUnhiddenWord()); | |
this.resetGame(); | |
} | |
}, | |
getUnhiddenWord() { | |
let word = ""; | |
for (const letter of this.hiddenWord) { | |
word += letter.letter; | |
} | |
return word; | |
}, | |
playerWins() { | |
// If there's at least a hidden letter, the player hasn't win yet | |
for (const letter of this.hiddenWord) { | |
if (letter.hidden) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
playerLoses() { | |
return this.remainingAttempts <= 0; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment