octokatherine / word-master

A Mastermind-like word guessing game
MIT License
377 stars 239 forks source link

Show invalid words on word completion instead of enter #136

Open RobinSmithCA opened 2 years ago

RobinSmithCA commented 2 years ago

When the entered word is invalid, I must use an extra keystroke to hit 'enter' only to have the circles come up red. Could the validity test not be done on entry of my final letter?

LWChris commented 1 year ago

Currently the validity check is inside the routine of the solution check that is triggered when you press "Enter".

Basically, when you press enter, the solution check runs through several stages of checks, returning with the most appropriate error message when a check fails. "Not a valid word" is just one of them, along with "Less than 5 letters have been entered" etc.

Since Easy mode does not require a valid word, it's easy to implement it this way where you just skip this particular check for that mode. However, I'm confident the code could probably be changed to a multi-level solution check, one that is run on each letter (conflicting hints), one that is run when you hit 5 letters (valid word), and one on "Enter", which behaved like it does now, i. e. explicitly checks for everything and is also the only one that can possibly "lock in" an answer and count towards the attempts.