parent
c34013313e
commit
3194cb8728
41 changed files with 432 additions and 443 deletions
@ -1,2 +1,3 @@ |
||||
TODO.txt |
||||
node_modules |
||||
.DS_STORE |
||||
|
@ -0,0 +1,35 @@ |
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import * as ModeActions from './actions/mode.actions'; |
||||
|
||||
import Board from './components/board/board.component'; |
||||
import Welcome from './components/welcome/welcome.component'; |
||||
|
||||
export const SETTINGS = { |
||||
GRID_WIDTH: 3, |
||||
GRID_HEIGHT: 3, |
||||
LIVES: 3 |
||||
}; |
||||
|
||||
export default class App extends Component { |
||||
render() { |
||||
const { mode, dispatch } = this.props; |
||||
console.log(dispatch) |
||||
|
||||
switch (this.props.mode) { |
||||
case ModeActions.WELCOME: |
||||
return <Welcome />; |
||||
case ModeActions.BOARD: |
||||
return <Board dispatch={this.props.dispatch} />; |
||||
} |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return { |
||||
mode: state.mode |
||||
} |
||||
}; |
||||
|
||||
export default connect(select)(App); |
@ -0,0 +1,18 @@ |
||||
// Grid component actions and action creators.
|
||||
export const GRID_ACTION = 'GRID_ACTION'; |
||||
export const GENERATE = 'GENERATE'; |
||||
export const UPDATE = 'UPDATE'; |
||||
|
||||
export const generateValues = (count, level) => ({ |
||||
type: GRID_ACTION, |
||||
action: GENERATE, |
||||
count: count, |
||||
level: level |
||||
}); |
||||
|
||||
export const updateValues = (i, level) => ({ |
||||
type: GRID_ACTION, |
||||
action: UPDATE, |
||||
index: i, |
||||
level: level |
||||
}); |
@ -0,0 +1,32 @@ |
||||
// Muncher component actions and action creators.
|
||||
export const MUNCHER_ACTION = 'MUNCHER_ACTION'; |
||||
export const LEFT = 'LEFT'; |
||||
export const RIGHT = 'RIGHT'; |
||||
export const UP = 'UP'; |
||||
export const DOWN = 'DOWN'; |
||||
export const MUNCH = 'MUNCH'; |
||||
|
||||
export const moveLeft = () => ({ |
||||
type: MUNCHER_ACTION, |
||||
action: LEFT |
||||
}); |
||||
|
||||
export const moveRight = () => ({ |
||||
type: MUNCHER_ACTION, |
||||
action: RIGHT |
||||
}); |
||||
|
||||
export const moveUp = () => ({ |
||||
type: MUNCHER_ACTION, |
||||
action: UP |
||||
}); |
||||
|
||||
export const moveDown = () => ({ |
||||
type: MUNCHER_ACTION, |
||||
action: DOWN |
||||
}); |
||||
|
||||
export const munch = () => ({ |
||||
type: MUNCHER_ACTION, |
||||
action: MUNCH |
||||
}); |
@ -0,0 +1,8 @@ |
||||
// Scorebar component actions and action creators.
|
||||
export const SCOREBAR_ACTION = 'SCOREBAR_ACTION'; |
||||
export const UPDATE = 'UPDATE'; |
||||
|
||||
export const update = () => ({ |
||||
type: SCOREBAR_ACTION, |
||||
action: UPDATE |
||||
}); |
@ -0,0 +1,14 @@ |
||||
// Game mode actions and action creators.
|
||||
export const MODE_ACTION = 'MODE_ACTION'; |
||||
export const WELCOME = 'WELCOME'; |
||||
export const BOARD = 'BOARD'; |
||||
|
||||
export const welcomeMode = () => ({ |
||||
type: MODE_ACTION, |
||||
action: WELCOME |
||||
}); |
||||
|
||||
export const boardMode = () => ({ |
||||
type: MODE_ACTION, |
||||
action: BOARD |
||||
}); |
@ -0,0 +1,8 @@ |
||||
// New game component actions and action creators.
|
||||
export const NEWGAME_ACTION = 'NEWGAME_ACTION'; |
||||
export const BLINK = 'BLINK'; |
||||
|
||||
export const blink = () => ({ |
||||
type: NEWGAME_ACTION, |
||||
action: BLINK |
||||
}); |
@ -0,0 +1,31 @@ |
||||
require('../../sass/board/board.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import Scorebar from './scorebar.component'; |
||||
// import Titlebar from './Titlebar';
|
||||
import Grid from './grid.component'; |
||||
// import Message from './Message';
|
||||
import Muncher from './muncher.component'; |
||||
|
||||
import * as GridActions from '../../actions/board/grid.actions'; |
||||
import * as MuncherActions from '../../actions/board/muncher.actions'; |
||||
import * as ScorebarActions from '../../actions/board/scorebar.actions'; |
||||
|
||||
export default class Board extends Component { |
||||
// A "munch" event affects several children. It needs a dispatch reference.
|
||||
munch() { |
||||
this.props.dispatch(GridActions.updateValues(0, 0)); |
||||
this.props.dispatch(MuncherActions.munch()); |
||||
this.props.dispatch(ScorebarActions.update()); |
||||
}; |
||||
|
||||
render() { |
||||
// <Titlebar />
|
||||
// <Message />
|
||||
return (<div className='board'> |
||||
<Scorebar /> |
||||
<Grid /> |
||||
<Muncher munch={this.munch} /> |
||||
</div>); |
||||
}; |
||||
}; |
@ -0,0 +1,36 @@ |
||||
require('../../sass/board/grid.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import GridCell from './grid-cell.component'; |
||||
import * as Actions from '../../actions/board/grid.actions'; |
||||
import { SETTINGS } from '../../App'; |
||||
|
||||
export default class Grid extends Component { |
||||
componentDidMount(n) { |
||||
this.props.dispatch(Actions.generateValues(SETTINGS.GRID_WIDTH * SETTINGS.GRID_HEIGHT, 1)); |
||||
}; |
||||
|
||||
render() { |
||||
const { values } = this.props; |
||||
const cells = []; |
||||
let i; |
||||
|
||||
for (let x = 0; x < SETTINGS.GRID_WIDTH; x++) { |
||||
for (let y = 0; y < SETTINGS.GRID_HEIGHT; y++) { |
||||
i = y * SETTINGS.GRID_WIDTH + x; |
||||
cells.push(<GridCell value={values[i]} x={x} y={y} key={i} />); |
||||
} |
||||
} |
||||
|
||||
return (<div className='grid'>{cells}</div>); |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return { |
||||
values: state.grid |
||||
} |
||||
}; |
||||
|
||||
export default connect(select)(Grid); |
@ -0,0 +1,25 @@ |
||||
require('../../sass/board/scorebar.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
export default class Scorebar extends Component { |
||||
render() { |
||||
var lives = []; |
||||
for (var i = 0; i < this.props.lives; i++) { |
||||
lives.push(<div className='life' key={i}></div>); |
||||
} |
||||
|
||||
return (<div className='scorebar'> |
||||
<div className='item current-score'>{this.props.current}</div> |
||||
<div className='item high-score'>{this.props.high}</div> |
||||
<div className='item lives'>{lives}</div> |
||||
</div>); |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return state.scorebar; |
||||
}; |
||||
|
||||
export default connect(select)(Scorebar); |
@ -1,7 +1,7 @@ |
||||
require('../../sass/welcome/highscores.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import HighScoreEntry from './HighScoreEntry'; |
||||
import HighScoreEntry from './high-score-entry.component'; |
||||
|
||||
export default class HighScores extends Component { |
||||
render() { |
@ -0,0 +1,51 @@ |
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import * as ModeActions from '../../actions/mode.actions'; |
||||
import * as NewGameActions from '../../actions/welcome/new-game.actions'; |
||||
|
||||
let blinkTimer = null; |
||||
let newgameListener = null; |
||||
|
||||
const toggleTimeout = function() { |
||||
var hidden = this.props.blink; |
||||
this.props.dispatch(NewGameActions.blink()); |
||||
blinkTimer = setTimeout(toggleTimeout.bind(this), 600); |
||||
}; |
||||
|
||||
export default class NewGame extends Component { |
||||
componentDidMount() { |
||||
newgameListener = this.handleKeydown.bind(this); |
||||
window.addEventListener('keydown', newgameListener); |
||||
// toggleTimeout.call(this);
|
||||
}; |
||||
|
||||
componentWillUnmount() { |
||||
window.removeEventListener('keydown', newgameListener); |
||||
clearTimeout(blinkTimer); |
||||
}; |
||||
|
||||
handleKeydown(e) { |
||||
if (e.keyCode === 32) { |
||||
this.props.dispatch(ModeActions.boardMode()); |
||||
} |
||||
}; |
||||
|
||||
render() { |
||||
const classname = ['newgame']; |
||||
|
||||
if (this.props.blink === true) { |
||||
classname.push('hidden'); |
||||
} |
||||
|
||||
return ( |
||||
<div className={classname.join(' ')}>Press Space Bar To Play</div> |
||||
); |
||||
}; |
||||
}; |
||||
//
|
||||
// const select = (state) => {
|
||||
// return state.newgame;
|
||||
// };
|
||||
//
|
||||
// export default connect(select)(NewGame);
|
@ -0,0 +1,19 @@ |
||||
require('../../sass/welcome/welcome.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
|
||||
import NewGame from './new-game.component'; |
||||
import HighScores from './high-scores.component'; |
||||
|
||||
export default class Welcome extends Component { |
||||
|
||||
render() { |
||||
return ( |
||||
<div className='welcome'> |
||||
<img src="res/title.png" /> |
||||
<NewGame /> |
||||
<HighScores /> |
||||
</div> |
||||
); |
||||
}; |
||||
}; |
@ -0,0 +1,29 @@ |
||||
require('./sass/reset.scss'); |
||||
|
||||
import { render } from 'react-dom'; |
||||
import { createStore, combineReducers } from 'redux' |
||||
import { Provider } from 'react-redux'; |
||||
|
||||
import App from './App'; |
||||
import modeReducer from './reducers/mode.reducer'; |
||||
import newgameReducer from './reducers/welcome/new-game.reducer'; |
||||
import gridReducer from './reducers/board/grid.reducer'; |
||||
import muncherReducer from './reducers/board/muncher.reducer'; |
||||
import scorebarReducer from './reducers/board/scorebar.reducer'; |
||||
|
||||
const combinedReducers = combineReducers({ |
||||
mode: modeReducer, |
||||
newgame: newgameReducer, |
||||
muncher: muncherReducer, |
||||
scorebar: scorebarReducer, |
||||
grid: gridReducer |
||||
}); |
||||
|
||||
const store = createStore(combinedReducers); |
||||
|
||||
ReactDOM.render( |
||||
<Provider store={store}> |
||||
<App /> |
||||
</Provider>, |
||||
document.getElementById('app') |
||||
); |
@ -1,27 +0,0 @@ |
||||
import React, { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import Board from '../board/Board'; |
||||
import Welcome from '../welcome/Welcome'; |
||||
import { MODE } from './Constants'; |
||||
|
||||
export class App extends Component { |
||||
render() { |
||||
const { mode } = this.props; |
||||
|
||||
switch (mode) { |
||||
case MODE.WELCOME: |
||||
return <Welcome />; |
||||
case MODE.BOARD: |
||||
return <Board />; |
||||
} |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return { |
||||
mode: state.mode |
||||
} |
||||
}; |
||||
|
||||
export default connect(select)(App); |
@ -1,23 +0,0 @@ |
||||
export const MODE = { |
||||
WELCOME: 'WELCOME', |
||||
BOARD: 'BOARD', |
||||
NEXT: 'NEXT' |
||||
}; |
||||
|
||||
export const BLINK = { |
||||
TOGGLE: 'TOGGLE' |
||||
}; |
||||
|
||||
export const VALUES = { |
||||
FOO: 'FOO', |
||||
GENERATE: 'GENERATE', |
||||
UPDATE: 'UPDATE' |
||||
}; |
||||
|
||||
export const MUNCHER = { |
||||
MOVE: 'MOVE', |
||||
LEFT: 'LEFT', |
||||
RIGHT: 'RIGHT', |
||||
UP: 'UP', |
||||
DOWN: 'DOWN' |
||||
}; |
@ -1,29 +0,0 @@ |
||||
import { MODE, BLINK, VALUES, MUNCHER } from './Constants'; |
||||
|
||||
export const nextMode = |
||||
() => ({ type: MODE.NEXT }); |
||||
|
||||
export const toggleBlink = |
||||
() => ({ type: BLINK.TOGGLE }); |
||||
|
||||
export const generateValues = |
||||
(count, level) => ({ |
||||
type: VALUES.FOO, |
||||
action: VALUES.GENERATE, |
||||
count: count, |
||||
level: level |
||||
}); |
||||
|
||||
export const updateValues = |
||||
(i, level) => ({ |
||||
type: VALUES.FOO, |
||||
action: VALUES.UPDATE, |
||||
index: i, |
||||
level: level |
||||
}); |
||||
|
||||
export const moveMuncher = |
||||
(direction) => ({ |
||||
type: MUNCHER.MOVE, |
||||
direction: direction |
||||
}); |
@ -1,61 +0,0 @@ |
||||
import { MODE, VALUES, BLINK, MUNCHER } from './Constants.js'; |
||||
|
||||
import { Values } from '../board/Values'; |
||||
import { GRID } from './Settings'; |
||||
|
||||
export const modeReducer = (state = MODE.WELCOME, action) => { |
||||
if (action.type === MODE.NEXT) { |
||||
switch (state) { |
||||
case MODE.BOARD: |
||||
return MODE.WELCOME; |
||||
case MODE.WELCOME: |
||||
return MODE.BOARD; |
||||
}; |
||||
} |
||||
|
||||
return MODE.BOARD; |
||||
}; |
||||
|
||||
export const blinkReducer = (state = false, action) => { |
||||
if (action.type === BLINK.TOGGLE) { |
||||
return (state ? false : true); |
||||
} |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
export const valuesReducer = (state = [], action) => { |
||||
if (action.type === VALUES.FOO) { |
||||
switch (action.action) { |
||||
case VALUES.GENERATE: |
||||
return Values.generate(action.count, action.level); |
||||
case VALUES.UPDATE: |
||||
const valid = Values.validate(state[action.index], action.level); |
||||
const results = state.slice(0); |
||||
if (valid) { |
||||
results[action.index] = ""; |
||||
} |
||||
return results; |
||||
} |
||||
} |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
const muncherInitialState = { x: 0, y: 0 }; |
||||
export const muncherReducer = (state = muncherInitialState, action) => { |
||||
if (action.type === MUNCHER.MOVE) { |
||||
switch (action.direction) { |
||||
case MUNCHER.LEFT: |
||||
return (state.x > 0 ? { x: state.x - 1, y: state.y } : state); |
||||
case MUNCHER.RIGHT: |
||||
return (state.x < GRID.W - 1 ? { x: state.x + 1, y: state.y } : state); |
||||
case MUNCHER.UP: |
||||
return (state.y > 0 ? { x: state.x, y: state.y - 1 } : state); |
||||
case MUNCHER.DOWN: |
||||
return (state.y < GRID.H - 1 ? { x: state.x, y: state.y + 1 } : state); |
||||
}; |
||||
} |
||||
|
||||
return state; |
||||
}; |
@ -1,4 +0,0 @@ |
||||
export const GRID = { |
||||
W: 3, |
||||
H: 3 |
||||
} |
@ -1,20 +0,0 @@ |
||||
require('../../sass/board/board.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import Scorebar from './Scorebar'; |
||||
import Titlebar from './Titlebar'; |
||||
import Grid from './Grid'; |
||||
import Message from './Message'; |
||||
import Muncher from './Muncher'; |
||||
|
||||
export default class Board extends Component { |
||||
render() { |
||||
return (<div className='board'> |
||||
<Scorebar /> |
||||
<Titlebar /> |
||||
<Message /> |
||||
<Grid /> |
||||
<Muncher /> |
||||
</div>); |
||||
} |
||||
}; |
@ -1,47 +0,0 @@ |
||||
require('../../sass/board/grid.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import GridCell from './GridCell'; |
||||
import * as creators from '../app/Creators'; |
||||
import { GRID } from '../app/Settings'; |
||||
|
||||
export default class Grid extends Component { |
||||
componentDidMount(n) { |
||||
this.props.dispatch(creators.generateValues(GRID.W * GRID.H, 1)); |
||||
// State.subscribe('level/next', this.levelNext);
|
||||
}; |
||||
|
||||
checkComplete() { |
||||
// if (Values.checkComplete(this.state.values, State.level) === true) {
|
||||
// State.publish('level/complete');
|
||||
// }
|
||||
}; |
||||
|
||||
levelNext() { |
||||
// this.setState({ values: this.generateValues() });
|
||||
}; |
||||
|
||||
render() { |
||||
const { values, dispatch } = this.props; |
||||
const cells = []; |
||||
let i; |
||||
|
||||
for (let x = 0; x < GRID.W; x++) { |
||||
for (let y = 0; y < GRID.H; y++) { |
||||
i = y * GRID.W + x; |
||||
cells.push(<GridCell value={values[i]} x={x} y={y} key={i} />); |
||||
} |
||||
} |
||||
|
||||
return (<div className='grid'>{cells}</div>); |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return { |
||||
values: state.values |
||||
} |
||||
}; |
||||
|
||||
export default connect(select)(Grid); |
@ -1,35 +0,0 @@ |
||||
/** |
||||
* THIS is the Board class. |
||||
*/ |
||||
module.exports = { |
||||
keydown(e) { |
||||
var x = this.refs.muncher.state.x; |
||||
var y = this.refs.muncher.state.y; |
||||
|
||||
switch (e.keyCode) { |
||||
case 32: |
||||
this.refs.grid.munch(x, y); |
||||
break; |
||||
|
||||
case 37: // Left arrow
|
||||
if (x > 0) { |
||||
this.refs.muncher.setState({ x: x - 1 }); |
||||
} |
||||
break; |
||||
case 38: // Up arrow
|
||||
if (y > 0) { |
||||
this.refs.muncher.setState({ y: y - 1 }); |
||||
} |
||||
break; |
||||
case 39: // Right arrow
|
||||
if (x < this.refs.grid.props.width - 1) { |
||||
this.refs.muncher.setState({ x: x + 1 }); |
||||
} |
||||
break; |
||||
case 40: // Down arrow
|
||||
if (y < this.refs.grid.props.height - 1) { |
||||
this.refs.muncher.setState({ y: y + 1 }); |
||||
} |
||||
} |
||||
} |
||||
}; |
@ -1,41 +0,0 @@ |
||||
require('../../sass/board/scorebar.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
|
||||
export default class Scorebar extends Component { |
||||
// getInitialState() {
|
||||
// return {
|
||||
// currentScore: 0,
|
||||
// highScore: 0,
|
||||
// lives: 3
|
||||
// };
|
||||
// },
|
||||
|
||||
componentDidMount() { |
||||
// // State.subscribe('munch/successful', this.updateScore);
|
||||
// State.subscribe('munch/failed', this.updateLives);
|
||||
}; |
||||
|
||||
updateScore() { |
||||
// var score = this.state.currentScore;
|
||||
// this.setState({ currentScore: score + 10 });
|
||||
}; |
||||
|
||||
updateLives() { |
||||
// var lives = this.state.lives;
|
||||
// this.setState({ lives: lives - 1 });
|
||||
}; |
||||
|
||||
render() { |
||||
var lives = []; |
||||
for (var i = 0; i < 3; i++) { |
||||
lives.push(<div className='life' key={i}></div>); |
||||
} |
||||
|
||||
return (<div className='scorebar'> |
||||
<div className='item current-score'>0</div> |
||||
<div className='item high-score'>0</div> |
||||
<div className='item lives'>{lives}</div> |
||||
</div>); |
||||
}; |
||||
}; |
@ -1,24 +0,0 @@ |
||||
require('../sass/reset.scss'); |
||||
|
||||
import { render } from 'react-dom'; |
||||
import { createStore, combineReducers } from 'redux' |
||||
import { Provider } from 'react-redux'; |
||||
|
||||
import App from './app/App'; |
||||
import * as reducers from './app/Reducers'; |
||||
|
||||
const combinedReducers = combineReducers({ |
||||
mode: reducers.modeReducer, |
||||
blink: reducers.blinkReducer, |
||||
values: reducers.valuesReducer, |
||||
muncher: reducers.muncherReducer |
||||
}); |
||||
|
||||
const store = createStore(combinedReducers); |
||||
|
||||
ReactDOM.render( |
||||
<Provider store={store}> |
||||
<App /> |
||||
</Provider>, |
||||
document.getElementById('app') |
||||
); |
@ -1,41 +0,0 @@ |
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import * as creators from '../app/Creators.js'; |
||||
|
||||
let blinkTimer = null; |
||||
|
||||
const toggleTimeout = function() { |
||||
var hidden = this.props.blink; |
||||
this.props.dispatch(creators.toggleBlink()); |
||||
blinkTimer = setTimeout(toggleTimeout.bind(this), 600); |
||||
}; |
||||
|
||||
export default class NewGame extends Component { |
||||
componentDidMount() { |
||||
toggleTimeout.call(this); |
||||
}; |
||||
|
||||
componentWillUnmount() { |
||||
clearTimeout(blinkTimer); |
||||
}; |
||||
|
||||
render() { |
||||
const classname = ['newgame']; |
||||
|
||||
if (this.props.blink === true) { |
||||
classname.push('hidden'); |
||||
} |
||||
|
||||
return ( |
||||
<div className={classname.join(' ')}>Press Space Bar To Play</div> |
||||
); |
||||
}; |
||||
}; |
||||
|
||||
const select = (state) => { |
||||
return { |
||||
blink: state.blink |
||||
} |
||||
}; |
||||
|
||||
export default connect(select)(NewGame); |
@ -1,39 +0,0 @@ |
||||
require('../../sass/welcome/welcome.scss'); |
||||
|
||||
import { Component } from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import * as creators from '../app/Creators.js'; |
||||
|
||||
import NewGame from './NewGame'; |
||||
import HighScores from './HighScores'; |
||||
|
||||
let listener = null; |
||||
|
||||
export class Welcome extends Component { |
||||
handleKeydown(e) { |
||||
if (e.keyCode === 32) { |
||||
this.props.dispatch(creators.nextMode()); |
||||
} |
||||
}; |
||||
|
||||
componentDidMount() { |
||||
listener = this.handleKeydown.bind(this); |
||||
window.addEventListener('keydown', listener); |
||||
}; |
||||
|
||||
componentWillUnmount() { |
||||
window.removeEventListener('keydown', listener); |
||||
}; |
||||
|
||||
render() { |
||||
return ( |
||||
<div className='welcome'> |
||||
<img src="res/title.png" /> |
||||
<NewGame /> |
||||
<HighScores /> |
||||
</div> |
||||
); |
||||
} |
||||
}; |
||||
|
||||
export default connect(() => ({}))(Welcome); |
@ -1,24 +0,0 @@ |
||||
0 info it worked if it ends with ok |
||||
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ] |
||||
2 info using npm@3.7.3 |
||||
3 info using node@v5.8.0 |
||||
4 verbose stack Error: missing script: start |
||||
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:147:19) |
||||
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:57:5 |
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 |
||||
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) |
||||
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) |
||||
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) |
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:300:12 |
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 |
||||
4 verbose stack at tryToString (fs.js:414:3) |
||||
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12) |
||||
5 verbose cwd /Users/tonklin/Development/bb/number-munchers |
||||
6 error Darwin 15.3.0 |
||||
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start" |
||||
8 error node v5.8.0 |
||||
9 error npm v3.7.3 |
||||
10 error missing script: start |
||||
11 error If you need help, you may report this error at: |
||||
11 error <https://github.com/npm/npm/issues> |
||||
12 verbose exit [ 1, true ] |
@ -0,0 +1,25 @@ |
||||
require('immutable'); |
||||
import * as GridActions from '../../actions/board/grid.actions'; |
||||
import Values from '../Values'; |
||||
|
||||
const reducer = (state = [], action) => { |
||||
if (action.type !== GridActions.GRID_ACTION) { |
||||
return state; |
||||
} |
||||
|
||||
switch (action.action) { |
||||
case GridActions.GENERATE: |
||||
return Values.generate(action.count, action.level); |
||||
case GridActions.UPDATE: |
||||
// const valid = Values.validate(state[action.index], action.level);
|
||||
const results = state.slice(0); |
||||
// if (valid) {
|
||||
results[action.index] = ""; |
||||
// }
|
||||
return results; |
||||
} |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
export default reducer; |
@ -0,0 +1,26 @@ |
||||
require('immutable'); |
||||
import * as MuncherActions from '../../actions/board/muncher.actions'; |
||||
|
||||
const reducer = (state = { x: 0, y: 0 }, action) => { |
||||
if (action.type !== MuncherActions.MUNCHER_ACTION) { |
||||
return state; |
||||
} |
||||
|
||||
switch (action.action) { |
||||
case MuncherActions.LEFT: |
||||
return { x: state.x - 1, y: state.y }; |
||||
case MuncherActions.RIGHT: |
||||
return { x: state.x + 1, y: state.y }; |
||||
case MuncherActions.UP: |
||||
return { x: state.x, y: state.y - 1 }; |
||||
case MuncherActions.DOWN: |
||||
return { x: state.x, y: state.y + 1 }; |
||||
case MuncherActions.MUNCH: |
||||
console.log("Muncher's mouth moved!"); |
||||
return state; |
||||
} |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
export default reducer; |
@ -0,0 +1,19 @@ |
||||
require('immutable'); |
||||
import * as ScorebarActions from '../../actions/board/scorebar.actions'; |
||||
import Values from '../Values'; |
||||
import { SETTINGS } from '../../App'; |
||||
|
||||
const reducer = (state = { current: 100, high: 999, lives: SETTINGS.LIVES }, action) => { |
||||
if (action.type !== ScorebarActions.SCOREBAR_ACTION) { |
||||
return state; |
||||
} |
||||
|
||||
switch (action.action) { |
||||
case ScorebarActions.UPDATE: |
||||
return { current: state.current + 10, high: 999 }; |
||||
} |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
export default reducer; |
@ -0,0 +1,12 @@ |
||||
require('immutable'); |
||||
import * as ModeActions from '../actions/mode.actions'; |
||||
|
||||
const reducer = (state = ModeActions.WELCOME, action) => { |
||||
if (action.type !== ModeActions.MODE_ACTION) { |
||||
return state; |
||||
} |
||||
|
||||
return action.action; |
||||
}; |
||||
|
||||
export default reducer; |
@ -0,0 +1,16 @@ |
||||
require('immutable'); |
||||
import * as NewGameActions from '../../actions/welcome/new-game.actions'; |
||||
|
||||
const reducer = (state = false, action) => { |
||||
// if (action.type !== NewGameActions.NEWGAME_ACTION) {
|
||||
// return state;
|
||||
// }
|
||||
//
|
||||
// if (action.action === NewGameActions.BLINK) {
|
||||
// return (state ? false : true);
|
||||
// }
|
||||
|
||||
return false; |
||||
}; |
||||
|
||||
export default reducer; |
Loading…
Reference in new issue