Hi, could anybody help with task250 stage 16? I have "3. The purchase of a new producer should change production rate according to the current tickSpeed. Hint: it should become smaller."
I tried to do this as in my handleKeyPress function as:
const productionRate =
(state.producers.baseProduction / 1000) * state.tickSpeed;
state.productionRate += productionRate;
But it isn't passed... No idea what's wrong 🙁
Full handlers.js bellow
import {
updateGold,
checkInitCompleted,
updateProducerList,
formatNumber,
} from './functions.js';
export const handleKeyPress = (term, state) => {
return (name, matches, data) => {
const key = String.fromCharCode(data.code);
if (key === 'G' || key === 'g') {
state.gold++;
} else {
for (let i = 0; i < state.producers.length; i++) {
if (key === String(state.producers[i].id - 1)) {
state.gold -= state.producers[i].cost;
state.producers[i].cost *= state.producers[i].growthRate;
state.producers[i].count++;
const productionRate =
(state.producers[i].baseProduction / 1000) * state.tickSpeed;
state.productionRate += productionRate;
term.moveTo(25, 3);
const speed = (state.productionRate * 1000) / state.tickSpeed;
term.green(formatNumber(speed));
term.green(formatNumber(state.gold));
}
}
}
if (!state.isInitCompleted) {
for (let i = 0; i < state.producers.length; i++) {
if (state.gold >= state.producers[i].cost) {
state.isInitCompleted = true;
checkInitCompleted(term, state);
}
}
}
if (!state.isProducerListUpdated) {
updateProducerList(term, state);
}
};
};
export const handleStateChange = (term, state) => {
return () => {
updateGold(term, state);
};
};
http://prntscr.com/1vb81qv