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
956 B

import * as WelcomeActions from '../../actions/welcome/welcome.actions';
import InitialsCtrl from './initials.controller';
import SETTINGS from '../../AppSettings';
let dispatch;
let update = true;
const HighScoreCtrl = {
setDispatch: (d) => dispatch = d,
keydown: (e) => {
if (update === true) {
InitialsCtrl.keydown(e);
}
else if (e.keyCode === 32) {
this.props.dispatch(ModeActions.options());
}
},
getHighScore: () => {
const scores = localStorage.getItem(SETTINGS.LOCAL_STORAGE_KEY);
if (scores !== null) {
return scores[0].score;
}
return 0;
},
gameOver: (score) => {
},
retrieveScores: () => {
const scores = localStorage.getItem(SETTINGS.LOCAL_STORAGE_KEY);
if (scores !== null) {
dispatch(WelcomeActions.updateScores(scores));
}
}
};
export default HighScoreCtrl;