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.
43 lines
889 B
43 lines
889 B
import * as ScorebarActions from '../actions/board/scorebar.actions';
|
|
import { SETTINGS } from '../App';
|
|
|
|
let dispatch;
|
|
let lives = 3;
|
|
let currentScore = 0;
|
|
let highScore = 7;
|
|
|
|
const ScorebarCtrl = {
|
|
setDispatch: d => dispatch = d,
|
|
|
|
getCurrentScore: () => currentScore,
|
|
getHighScore: () => highScore,
|
|
getLives: () => lives,
|
|
|
|
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;
|
|
}
|
|
};
|
|
|
|
export default ScorebarCtrl;
|
|
|