#23Wordle 2
Overview
A simplified version of the previous Wordle challenge, with more pre-built components to make guessing a 5-letter word easier.
Requirements
- Display 6 rows representing the maximum number of guesses.
- Allow typing letters (via on-screen keyboard or physical keyboard) to fill the current row.
- Pressing "Enter" (or clicking Submit) submits the current word.
- Validate that the guessed word exists in the list of valid words.
- Color the tiles based on correctness:
- Green: correct letter in the correct position.
- Yellow: correct letter in the wrong position.
- Gray: letter not in the word.
- Update the on-screen keyboard keys to reflect discovered letter statuses.
- Display a message when:
- The word is not valid.
- The player wins (
You win!). - The player loses (
You lost! <solution>).
- Disable further input after a win or after 6 incorrect guesses.
- Implement a "delete" action to remove the last typed letter.
- Ensure that rows cannot exceed 5 letters.
- Keep the message empty after submitting a valid but incorrect word.
Notes
- Most UI components are pre-built:
RowandTilehandle rendering of letters and colors.Keyboardrenders all keys and manages basic click events.
- Focus on implementing the game logic inside
handleOnKeyPress:- Add letters to
word. - Submit a guess and update
guesses. - Validate words against the
validWordslist. - Handle win and loss conditions.
- Delete letters correctly.
- Add letters to
- Update
getKeyStatusto reflect correct, present, or absent letters on the keyboard. - Use the
SOLUTIONconstant as the word to guess. - Input should work both with on-screen keys and the physical keyboard.
Tests
- renders 6 rows and the keyboard keys
- typing a letter adds it to the current row
- typing a full word and submitting adds it to the guesses
- winning the game shows the victory message and blocks further input
- after 6 wrong guesses, game over message is shown and input is blocked
- typing an invalid word shows 'Not valid word' message and does not add to guesses
- delete removes the last letter from the current row
- does not allow adding more than 5 letters to a row
- blocks input after winning
- blocks input after losing
- message remains empty after submitting valid incorrect word
- typing letters with the physical keyboard adds them to the current row and second row empty
- keyboard keys update colors according to guesses
- board tiles update colors according to hello
- board tiles update colors according to hight