Open codyswanner opened 1 year ago
Sorry for monster write-up, and also for the following counter-argument (pretend I'm someone entirely different objecting to the original issue because that's what this is):
"exit," "reset," "undo," "settings" and any other special scenarios should be handled by userInputHandler, and userMove/promptUser should not be handling any of these special cases. From this perspective, userMove should still be updated (and we still need a fix for the user entering 0), but likely reduced, not expanded. I am less sure what exactly that looks like, since I'm less familiar with userInputHandler and what it would do to perform each of the actions I mentioned, and how userMove/promptUser would need to be reworked around those features.
Sorry again for the giant issue, this is what happens when I'm doing documentation review! 😁
I believe that all these scenarios should be handed to userInputHandler() which I've run into issues with handling exiting/restarting.
Currently userMove checks for a return from promptUser of (-1, -1), which corresponds to a user input of "exit" and when returned to terminalGame, exits the game. The way userMove is checking for this is shown below:
This works well as is, but if we decide to add additional features that could use this pathway, this method of checking could get in our way. The example I can come up with at this moment is an undo feature -- perhaps a user input of "undo" causes promptUser to return values (-2, -2) with the intention that this will be sent back up to terminalGame to perform the action. Currently, this will not be handled properly by the middleman userMove. If we want to use negative numbers as special codes for actions like exit and undo, I suggest making a change like this:
We could also change this check to validate user input; say for instance the user inputs a number outside of 1-9,* userMove could validate, find this input to be out of bounds, and prompt the user for a new input.
*it should not be possible to input a value greater than 9 as there is a check that user input is a single character; however, there is currently a bug on user input of 0
Basing this block on the last example should give us flexibility to add any kind of user-initiated features that we want through promptUser, while also validating user inputs to remove a bug.