import * as ScorebarActions from '../actions/board/scorebar.actions'; import { SETTINGS } from '../App'; let dispatch; let lives = 1; let currentScore = 0; let highScore = 7; let gameOver = false; const ScorebarCtrl = { setDispatch: d => dispatch = d, getCurrentScore: () => currentScore, getHighScore: () => highScore, getLives: () => lives, flagGameOver: () => gameOver = true, isGameOver: () => gameOver, munchSucceeded: () => { currentScore += 10; dispatch(ScorebarActions.update()); }, munchFailed: () => { lives--; currentScore -= 5; dispatch(ScorebarActions.update()); }, eatenByTroggle: () => { lives--; dispatch(ScorebarActions.update()); }, levelUp: (level) => { currentScore += 25; dispatch(ScorebarActions.update()); }, reset: () => { lives = SETTINGS.LIVES; currentScore = 0; gameOver = false; dispatch(ScorebarActions.update()); } }; export default ScorebarCtrl;