Skip to content

Commit

Permalink
Adding reset button
Browse files Browse the repository at this point in the history
Unfortunately, a lot of other minor tweaks snuck in here, but
now there is a reset button available. At this point, the product
is ready for larger use.

Crazy...

One day of soaking, and I'll probably make the world more aware
of it come Saturday.
  • Loading branch information
DaveSpringer committed May 25, 2017
1 parent 0f2c597 commit e1b80b4
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 18 deletions.
2 changes: 0 additions & 2 deletions dist/0.82dc086373a23a8fe216.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/0.82dc086373a23a8fe216.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions dist/0.d08ff7e1984567c9474a.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/0.d08ff7e1984567c9474a.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><title>Batman Miniature Game Dashboard</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16"><link href="https://fonts.googleapis.com/css?family=Teko|Cuprum|Cuprum:700" rel="stylesheet"><link href="/styles/main.0af52badcb6cd698513cbb5ca75af957.css" rel="stylesheet"></head><body><div id="root" style="height: 100%"></div><script type="text/javascript" src="/manifest.5d456d809c8b636db2f7.js"></script><script type="text/javascript" src="/normalize.a31107ff90dfd6013773.js"></script><script type="text/javascript" src="/vendor.eed8a87e8b9c88fc7487.js"></script><script type="text/javascript" src="/main.52840a2cfdedd82702be.js"></script></body></html>
<!doctype html><html lang="en"><head><title>Batman Miniature Game Dashboard</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16"><link href="https://fonts.googleapis.com/css?family=Teko|Cuprum|Cuprum:700" rel="stylesheet"><link href="/styles/main.3672d6d8dba23493a2dccac7e880f464.css" rel="stylesheet"></head><body><div id="root" style="height: 100%"></div><script type="text/javascript" src="/manifest.3f83faa4053a8fe162de.js"></script><script type="text/javascript" src="/normalize.a31107ff90dfd6013773.js"></script><script type="text/javascript" src="/vendor.eed8a87e8b9c88fc7487.js"></script><script type="text/javascript" src="/main.52840a2cfdedd82702be.js"></script></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/styles/main.0af52badcb6cd698513cbb5ca75af957.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/styles/main.3672d6d8dba23493a2dccac7e880f464.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"clean": "rimraf dist",
"compile": "node build/scripts/compile",
"build": "npm run clean && cross-env NODE_ENV=production npm run compile",
"build": "npm run clean && npm run lint:fix && npm run test && cross-env NODE_ENV=production npm run compile",
"start": "cross-env NODE_ENV=development PORT=3000 node build/scripts/start",
"serve": "cross-env NODE_ENV=production node build/scripts/start",
"test": "cross-env NODE_ENV=test karma start build/karma.config",
Expand Down
18 changes: 17 additions & 1 deletion src/resources/crews.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,23 @@ export const allCrews = [
id : 'bm'
}, {
name : 'Watchmen',
id : 'wm'
id : 'wm',
roster: [{
name: 'Rorschach',
boss: 'no'
}, {
name: 'Comedian',
boss: 'no'
}, {
name: 'Ozymandias',
boss: 'no'
}, {
name: 'Niteowl',
boss: 'no'
}, {
name: 'Silk Spectre II',
boss: 'no'
}]
}, {
name : 'Riddler',
id : 'rd'
Expand Down
10 changes: 9 additions & 1 deletion src/routes/Builder/components/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Builder extends React.Component {
super()
this.addAllCharactersClick = this.addAllCharactersClick.bind(this)
this.handleRulesChange = this.handleRulesChange.bind(this)
this.handleResetCrew = this.handleResetCrew.bind(this)
}
componentWillMount () {
// Load up the various files
Expand All @@ -27,6 +28,10 @@ class Builder extends React.Component {
this.props.followCrewRules(event.target.checked)
}

handleResetCrew (event) {
this.props.resetCrew()
}

render () {
let availableCharacters = this.props.crew.availableCharacters
return (
Expand All @@ -51,6 +56,8 @@ class Builder extends React.Component {
onChange={this.handleRulesChange} />
<span className='spacerSpan' />
<button className='addAllBtn' onClick={this.addAllCharactersClick}>Add All Models</button>
<span className='spacerSpan' />
<button className='addAllBtn' onClick={this.handleResetCrew}>Reset</button>
</div>
<div id='available-characters' className='character-area'>
{availableCharacters.map(character =>
Expand Down Expand Up @@ -105,7 +112,8 @@ Builder.propTypes = {
selectCharacter : React.PropTypes.func.isRequired,
loadResources : React.PropTypes.func.isRequired,
addAllCharacters : React.PropTypes.func.isRequired,
followCrewRules : React.PropTypes.func.isRequired
followCrewRules : React.PropTypes.func.isRequired,
resetCrew : React.PropTypes.func.isRequired
}

export default Builder
2 changes: 1 addition & 1 deletion src/routes/Builder/components/SelectHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SelectHeader extends React.Component {
inconsistent.</p>
<p>This site is really and truly in <b>alpha</b>. This is not a modern video
game beta-that-is-actually-a-demo or a Google beta-that-is-a-better-product-than-the-rest-of-the-world-can-make.</p>
<p>Trait descriptions here are not directly copied from the rule book,
<p>Trait descriptions here are not directly copied from the rule book,
and the rule book is the final authority. I didn't realize there was
a huge difference between Character and Model until probably the last
15 traits, so there are many traits that incorrectly reference Character
Expand Down
12 changes: 10 additions & 2 deletions src/routes/Builder/containers/BuilderContainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { connect } from 'react-redux'
import { selectCrew, selectCharacter, loadResources, addAllCharacters, followCrewRules } from '../modules/builder'
import {
selectCrew,
selectCharacter,
loadResources,
addAllCharacters,
followCrewRules,
resetCrew
} from '../modules/builder'

import Builder from '../components/Builder'

Expand All @@ -8,7 +15,8 @@ const mapDispatchToProps = {
selectCharacter,
loadResources,
addAllCharacters,
followCrewRules
followCrewRules,
resetCrew
}

const mapStateToProps = (state) => ({
Expand Down
26 changes: 25 additions & 1 deletion src/routes/Builder/modules/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const SELECT_CHARACTER = 'SELECT_CHARACTER'
export const LOAD_RESOURCES = 'LOAD_RESOURCES'
export const ADD_ALL_CHARACTERS = 'ADD_ALL_CHARACTERS'
export const FOLLOW_CREW_RULES = 'FOLLOW_CREW_RULES'
export const RESET_CREW = 'RESET_CREW'

// Actions

Expand Down Expand Up @@ -51,10 +52,19 @@ export function followCrewRules (followRules = true) {
}
}

export function resetCrew () {
return {
type: RESET_CREW
}
}

export const actions = {
selectCrew,
selectCharacter,
loadResources
loadResources,
addAllCharacters,
followCrewRules,
resetCrew
}

export const selectCrewAction = (state, action) => {
Expand Down Expand Up @@ -96,6 +106,7 @@ export const selectCrewAction = (state, action) => {
resultAvail.sort(sortCharacters)
return Object.assign({}, state, {
crewName: crewName,
crewId: action.crew.id,
availableCharacters : resultAvail,
characters : [],
hiddenCharacters : [],
Expand Down Expand Up @@ -148,6 +159,15 @@ export const followRules = (state, action) => {
return toggleFollowRules(state, action)
}

export const resetCurrentCrew = (state, action) => {
if (state.crewId === 'na' || state.crewName === 'default') {
return state
}
// Find the crew object
let crew = state.allCrews.find((crew) => crew.id === state.crewId && crew.name === state.crewName)
return selectCrewAction(state, { crew: crew })
}

// Action Handlers
const ACTION_HANDLERS = {
[SELECT_CREW] : (state, action) => {
Expand All @@ -164,11 +184,15 @@ const ACTION_HANDLERS = {
},
[FOLLOW_CREW_RULES]: (state, action) => {
return followRules(state, action)
},
[RESET_CREW]: (state, action) => {
return resetCurrentCrew(state, action)
}
}

const initialState = {
crewName : 'default',
crewId : 'na',
characters: [],
availableCharacters: [],
allCharacters: [],
Expand Down
49 changes: 48 additions & 1 deletion tests/routes/Builder/modules/builder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
LOAD_RESOURCES,
ADD_ALL_CHARACTERS,
FOLLOW_CREW_RULES,
RESET_CREW,
selectCrew,
selectCharacter,
loadResources,
addAllCharacters,
followCrewRules,
resetCrew,
default as builderReducer
} from 'routes/Builder/modules/builder'

Expand Down Expand Up @@ -195,7 +197,6 @@ describe('(Redux Module) Builder', () => {

it('Suicide Squad should have Free Agents that are not generically available.', () => {
expect(suicideSquadPopped).to.be.an('object')
console.log('Here it is: ' + JSON.stringify(suicideSquadPopped.availableCharacters.filter(filterCharacterAlias('Harley Quinn'))))
expect(suicideSquadPopped.availableCharacters.filter(filterCharacterAlias('Katana (Suicide Squad)')).length).to.be.above(0)
})

Expand All @@ -206,6 +207,18 @@ describe('(Redux Module) Builder', () => {
expect(character.rank).to.be.a('string')
})
})

let watchmenCrew = loadedState.allCrews.find((crew) => crew.id === 'wm')
let watchmenCrewPopped = builderReducer(loadedState, selectCrew(watchmenCrew))
it('Should be able to select the Watchmen.', () => {
expect(watchmenCrewPopped).to.be.an('object')
expect(watchmenCrewPopped.crewName).to.equal('Watchmen')
expect(watchmenCrewPopped.crewId).to.equal('wm')
})

it('Should only have the 5 Watchmen.', () => {
expect(watchmenCrewPopped.availableCharacters.length).to.equal(5)
})
})

describe('(ActionCreator) selectCharacter', () => {
Expand Down Expand Up @@ -292,4 +305,38 @@ describe('(Redux Module) Builder', () => {
expect(additionalState.followRules).to.equal(true)
})
})

describe('(ActionCreator) resetCrew', () => {
let loadedState = builderReducer(defaultState, loadResources())

describe('Suicide-Squad Reset Validator', () => {
let suicideSquadCrew = loadedState.allCrews.find((crew) => crew.id === 'ss')
let suicideSquadPopped = builderReducer(loadedState, selectCrew(suicideSquadCrew))
let allSelected = builderReducer(suicideSquadPopped, addAllCharacters())

it('Pretest validation', () => {
expect(allSelected.characters.length).to.equal(suicideSquadPopped.availableCharacters.length)
})

it('Should be able to reset an all selected crew.', () => {
let resetCrewState = builderReducer(allSelected, resetCrew())
expect(resetCrewState.availableCharacters.length).to.equal(suicideSquadPopped.availableCharacters.length)
})
})

describe('Batman Reset Validator', () => {
let batmanCrew = loadedState.allCrews.find((crew) => crew.id === 'bt')
let batmanCrewPopped = builderReducer(loadedState, selectCrew(batmanCrew))
let allSelected = builderReducer(batmanCrewPopped, addAllCharacters())

it('Pretest validation', () => {
expect(allSelected.characters.length).to.equal(batmanCrewPopped.availableCharacters.length)
})

it('Should be able to reset an all selected crew.', () => {
let resetCrewState = builderReducer(allSelected, resetCrew())
expect(resetCrewState.availableCharacters.length).to.equal(batmanCrewPopped.availableCharacters.length)
})
})
})
})

0 comments on commit e1b80b4

Please sign in to comment.