Hello! Can you help me to solve this
The purchase of a new producer should change production rate according to the current tickSpeed. Hint: it should become smaller.
Production rate printed to the screen should still represent the amount of gold earned each second
handler
export const handleKeyPress = (term, state) => {
return (name, matches, data) => {
const s = String.fromCharCode(data.code);
if (s === "G" || s === "g") {
updateGold(term, state);
}
state.producers.find((object) => {
if (object.id === Number(s) && state.gold >= object.cost) {
++object.count;
state.gold -= object.cost;
object.cost *= object.growthRate;
state.productionRate +=
(object.baseProduction * state.tickSpeed) / 1000; //stage 16 line
state.isInitCompleted = false;
state.isProducerListUpdated = false;
term.moveTo(25, 3);
}
});
if (!state.isInitCompleted) {
let cheapProd = state.producers[0];
state.producers.forEach((producers, i) => {
if (producers.cost < cheapProd) {
cheapProd = producers[i];
}
});
if (state.gold >= cheapProd.cost) {
state.isInitCompleted = true;
checkInitCompleted(term, state);
}
if (!state.isProducerListUpdated) {
updateProducerList(term, state);
state.isProducerListUpdated = true;
}
}
};
};
function
export const checkInitCompleted = (term, state) => {
term.clear();
term.moveTo(1, 4);
term.bold.green(
"You can purchase producers by clicking the number button (1, 2, 3, ...)"
);
term.moveTo(75, 4);
term.eraseLineAfter();
term.yellow(`GOLD: ${formatNumber(state.gold)}`);
term.moveTo(95, 4);
term.eraseLineAfter();
term.yellow(
`PRODUCTION RATE: ${formatNumber(
(state.productionRate * 1000) / state.tickSpeed
)}` //stage 16 line
);
state.isProducerListUpdated = false;
};