привет !!
Нужна помощь
solutions.js
import {startMiningGame} from './gameEngine';
import {term} from './constants';
import {init} from './functions'
startMiningGame(term);
init(term);
constants.js
import terminalKit from 'terminal-kit';
export const term = terminalKit.terminal;
export const config = {
gold:0
};
gameEngine.js
import {init} from './functions'
import { handleKeyPress } from './handlers';
export const startMiningGame = (term, config) => {
init(term);
term.on("key", handleKeyPress(term, state));
}
functions.js
export const init = (term) => {
term('Welcome to the mining game!');
term.clear();
term.hideCursor();
term.grabInput();
};
handlers.js
export const handleKeyPress = (term, state) => {
return (name, matches, data) => {
const key = String.fromCharCode(data.code);
if(key === 'g' || key === 'G'){
return state.gold ++
}
}
};