After implementing a producer purchase we need to make sure they do the work!
Each second the producer should give us the amount of gold equal to their baseProduction
.
- Add a new field
productionRate
to the config object exported fromconstants.js
. - Initial value of
productionRate
should equal to 0. - When the user purchases a new producer, we should increase the global
productionRate
- Implement and export a handler
handleStateChange(term, state)
inhandlers.js
that should call a functionupdateGold(term, state)
- In the
updateGold
function, increment the value of gold by productionRate each time it’s called - In
startMiningGame
set the interval that will callhandleStateChange
once every second handleStateChange
should be a closure and return a function in order to be used insetInterval
- Remove the call to
updateGold
from thehandleKeyPress
to avoid accounting issues
This task is part of the Full-Stack JavaScript Course.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.