Added a setInterval timer that just counts down every three seconds and shows that number in a new p.counter in the HTML. Removed some logic I had in there that made the number of trials a factor of trials + n as the umber of trials should not be a factor of the value of n. Changed trails default to 25. Added a trialDuration global variable, so this could be a user-facing setting later on.
Replaced the nextStep function with my new startTrials interval function. Call startTrials function off of startGame.
Got my timer all in and working. Now, when you hit play, a countdown timer starts. When the countdown is over, the game starts and the trials begin. When the trials are over, we display the score. Added a check inside the generateObjects function to check and see if the color of the new souvenir matches that of nBack.
Added functionality that checks to see if the current object is an nBack color match when the user clicks the color match button. If it is, the correct score gets updated. If it's not the incorrect score gets updated.
Added a bunch of notes for next steps to readme. Added logic to disable play button during the game and reenable it at the end. Reset the souvenirs array at the beginning of the generateObejcts function, so we can start with an empty array for each new game.
Disabled the color match button by default. Added logic to enable to color match button once we've reached n, so users can't guess what's 'n-back' if there is no n-back to match against yet. Added functionality to disable the color match button each time the user clicks it then, reenable it each time a new object is drawn.
Added more colors to my color array.
Added notes to readme file on how I plan to rewrite the property comparison logic so I can calculate when a user fails to click match when a match is presented.
Renamed my objectIndex variable to currentObject, to make code more readable. Renamed my compareProperty function to compareNback. Created an updateScore function that calls the compareNback function, checks to see if it's true or false and updates the 'correct' and 'incorrect' variables accordingly. Called the updateScore function off of the 'input.color' click event. This is all to setup my updateScore function so I can call it regardless of if the user clicks the 'input.color' match button or not.
Added some debug text and fixed a bug with the score getting updated incorrectly.
Added a global results variable. If the user inputs a color match click (indicating that they think there was a color match), the results variable keeps track of whether or not the user was correct. If the user does not provide a color match input, the computer checks whether or not there was a color match, and calculates if the lack of user response was was correct (because there was no match) or incorrect (because there was a match and the user didn't catch it).
Added a getResults function to scrub through the results array for true and false calculations for the final 'correct' and 'incorrect' tallies. Removed code any code that was incrementing the correct and incorrect variables outside of this function. Did a little cleanup, added comments, fixed indentation, removed stuff that was commented out that I no longer need.