You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.0 KiB

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