Task #250, Stage #16 - Gold Mine
At the moment, we’re updating the UI once a second. It’s ok, but it’d be a lot smoother if it was updating more often. Let’s say 10 times faster. You’ll need to change the code in quite a few places,...
At the moment, we’re updating the UI once a second. It’s ok, but it’d be a lot smoother if it was updating more often. Let’s say 10 times faster. You’ll need to change the code in quite a few places,...
Our game should interact with the user in 2 ways. It should know how to accept the keyboard input, and it should know how to print messages to the console....
So, you’ve already exported the constant term that will allow us to control the terminal. Let’s make some use of it! Create the file functions.js and export the function init from it....
Congratulations on passing the stage 3! You might be wondering why we have 4 files, a third party module and quite a few lines of code to output a single message on the screen… And the answer is that this structure will allow our code to be flexible,...
Now, let’s work on the function that will be called if the user clicks the key G on the keyboard. Implement and export the function handleKeyPress(term, state) in the handlers.js....
The handler is ready, so we need to connect it with the keypress event. But before that we need to improve the init function. It accepts a single parameter and should call on it:...
So, now we can start mining gold in manual mode by pressing key ‘G’ key. Let’s print the result of our actions on the screen. Implement and export the function updateGold(term, state) from functions....
Great! The manual mode is done, so we should think about automating our mining empire. Add a new field producers into the config constant that was exported from solution.js. It should be an array of objects....
Now let’s add the ability for the user to purchase new producers. If you’ve created producers with single digit ids, you did everything right. If not, you can still fix it....
The document has already added a title and five colored button elements. When you click on any of the buttons, the text color of the h2 heading should change to the one indicated on the button....