Hangman Game
Gameplay
Player guesses letters, and is prompted if the letter is correct or incorrect. The game is over when the player guesses all the letters in the word, or when all body parts of the Hangman have been drawn.
Scoring
Scores are based on the amount of letters correctly guessed before losing, and the size of the word. If all letters are correctly guessed, the game counts as a win.
Logic
The game is played asynchronously, without the need to refresh the page between guesses. It uses websockets with Razor pages, and makes use of click events for gameplay functionality.
sendButton.onclick = function () {
if (!socket || socket.readyState !== WebSocket.OPEN) {
alert("socket not connected");
}
var data = sendMessage.value;
…