Models hooked up to options.

master
Ben Burlingham 9 years ago
parent 09868fc8d1
commit e3a09c540e
  1. 2
      controllers/board/board.controller.js
  2. 7
      controllers/board/grid.controller.js
  3. 5
      controllers/board/titlebar.controller.js
  4. 2
      controllers/high-score/high-score.controller.js
  5. 31
      controllers/options/options.controller.js
  6. 2
      controllers/welcome/welcome.controller.js

@ -48,7 +48,7 @@ const BoardCtrl = {
}, },
keyListener(e) { keyListener(e) {
if (e.keyCode !== 32 && MessageCtrl.isShowing() === false) { if (e.keyCode !== 32 && e.keyCode !== 13 && MessageCtrl.isShowing() === false) {
MuncherCtrl.move(e); MuncherCtrl.move(e);
} }
else if (ScorebarCtrl.isGameOver()) { else if (ScorebarCtrl.isGameOver()) {

@ -1,21 +1,22 @@
import * as GridActions from '../../actions/board/grid.actions'; import * as GridActions from '../../actions/board/grid.actions';
import FactorsModel from '../../models/factors.model';
import SETTINGS from '../../AppSettings'; import SETTINGS from '../../AppSettings';
let values; let values;
let dispatch; let dispatch;
let model;
const GridCtrl = { const GridCtrl = {
setDispatch: d => dispatch = d, setDispatch: d => dispatch = d,
setModel: m => model = m,
getValues: () => values, getValues: () => values,
generateValues: (level) => { generateValues: (level) => {
values = FactorsModel.generate(SETTINGS.GRID_WIDTH * SETTINGS.GRID_HEIGHT, level); values = model.generate(SETTINGS.GRID_WIDTH * SETTINGS.GRID_HEIGHT, level);
dispatch(GridActions.update(values)); dispatch(GridActions.update(values));
}, },
isCompleted: (level) => { isCompleted: (level) => {
return FactorsModel.checkComplete(values, level) return model.checkComplete(values, level)
}, },
hideValue: (index) => { hideValue: (index) => {

@ -1,13 +1,14 @@
import * as TitlebarActions from '../../actions/board/titlebar.actions'; import * as TitlebarActions from '../../actions/board/titlebar.actions';
import FactorsModel from '../../models/factors.model';
let dispatch; let dispatch;
let model;
const TitlebarCtrl = { const TitlebarCtrl = {
setDispatch: d => dispatch = d, setDispatch: d => dispatch = d,
setModel: m => model = m,
setTitle: (level) => { setTitle: (level) => {
const title = FactorsModel.getTitle(level); const title = model.getTitle(level);
dispatch(TitlebarActions.update(title)); dispatch(TitlebarActions.update(title));
} }
}; };

@ -26,8 +26,6 @@ const HighScoreCtrl = {
} }
} }
console.log(found)
if (found === -1) { if (found === -1) {
dispatch(ModeActions.welcome()); dispatch(ModeActions.welcome());
} }

@ -1,5 +1,12 @@
import * as OptionsActions from '../../actions/options/options.actions'; import * as OptionsActions from '../../actions/options/options.actions';
import ModeCtrl from '../mode.controller'; import ModeCtrl from '../mode.controller';
import GridCtrl from '../board/grid.controller';
import TitlebarCtrl from '../board/titlebar.controller';
import MultiplesModel from '../../models/multiples.model';
import FactorsModel from '../../models/factors.model';
import AdditionModel from '../../models/addition.model';
import SubtractionModel from '../../models/subtraction.model';
let dispatch; let dispatch;
const values = ['Multiples', 'Factors', 'Addition', 'Subtraction']; const values = ['Multiples', 'Factors', 'Addition', 'Subtraction'];
@ -15,11 +22,25 @@ const OptionsCtrl = {
}, },
keyListener(e) { keyListener(e) {
if (e.keyCode === 32) { if (e.keyCode === 32 || e.keyCode === 13) {
let model = let model;
// switch (selected) { switch (selected) {
// case 0: case 0:
// } model = MultiplesModel;
break;
case 1:
model = FactorsModel;
break;
case 2:
model = AdditionModel;
break;
case 3:
model = SubtractionModel;
break;
}
GridCtrl.setModel(model);
TitlebarCtrl.setModel(model);
ModeCtrl.board(); ModeCtrl.board();
} }
else if (e.keyCode === 38) { else if (e.keyCode === 38) {

@ -23,7 +23,7 @@ const WelcomeCtrl = {
}, },
keydown: (e) => { keydown: (e) => {
if (e.keyCode === 32) { if (e.keyCode === 32 || e.keyCode === 13) {
dispatch(ModeActions.options()); dispatch(ModeActions.options());
} }
} }

Loading…
Cancel
Save