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.
27 lines
751 B
27 lines
751 B
const Immutable = require('immutable');
|
|
|
|
import * as ScorebarActions from '../../actions/board/scorebar.actions';
|
|
import Values from '../Values';
|
|
import { SETTINGS } from '../../App';
|
|
|
|
const reducer = (state = { current: 0, high: 999, lives: SETTINGS.LIVES }, action) => {
|
|
if (action.type !== ScorebarActions.SCOREBAR_ACTION) {
|
|
return state;
|
|
}
|
|
|
|
const result = Immutable.Map(state);
|
|
|
|
switch (action.action) {
|
|
case ScorebarActions.MUNCH:
|
|
if (action.success) {
|
|
return result.set('current', state.current + 10).toObject();
|
|
}
|
|
else {
|
|
return result.set('lives', state.lives - 1).toObject();
|
|
}
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|
|
export default reducer;
|
|
|