Я нашел!!!
import { updateGold} from "./functions.js"
export const handleKeyPress = (term, state)=>{
return (name, matches, data) =>{
if(String.fromCharCode(data.code)==="g" || String.fromCharCode(data.code)==="G"){
state.gold = state.gold + 1
updateGold(term,state)
}
for (let i = 0; i < state.producers.length; i++) {
if (String.fromCharCode(data.code)===``${state.producers[i].id}``) {
state.gold = state.gold - state.producers[i].cost
state.producers[i].cost = state.producers[i].cost*state.producers[i].growthRate
state.producers[i].count = state.producers[i].count + 1
updateGold(term,state)
}
else{
}
}
}
import terminalKit from 'terminal-kit';
export const term = terminalKit.terminal;
export const config = {gold:0, producers:[
{ id: 1, title: 'Miner', cost: 10, growthRate: 1.13, baseProduction: 0.1, count: 0 },
{ id: 2, title: 'Adventurer', cost: 100, growthRate: 1.17, baseProduction: 1, count: 0 },
{ id: 3, title: 'Professional', cost: 1200, growthRate: 1.14, baseProduction: 9, count: 0 }]}