fluxify it

This commit is contained in:
Peter Cottle 2015-08-29 08:45:53 -07:00
parent 78b87b3c47
commit de8d8221f5
4 changed files with 34 additions and 8 deletions

View file

@ -14,6 +14,12 @@ var GlobalStateActions = {
}); });
}, },
levelSolved: function() {
AppDispatcher.handleViewAction({
type: ActionTypes.LEVEL_SOLVED,
});
},
changeFlipTreeY: function(flipTreeY) { changeFlipTreeY: function(flipTreeY) {
AppDispatcher.handleViewAction({ AppDispatcher.handleViewAction({
type: ActionTypes.CHANGE_FLIP_TREE_Y, type: ActionTypes.CHANGE_FLIP_TREE_Y,

View file

@ -25,7 +25,13 @@ module.exports = {
CHANGE_FLIP_TREE_Y: null, CHANGE_FLIP_TREE_Y: null,
SUBMIT_COMMAND: null, SUBMIT_COMMAND: null,
CHANGE_LOCALE: null, CHANGE_LOCALE: null,
CHANGE_LOCALE_FROM_HEADER: null CHANGE_LOCALE_FROM_HEADER: null,
/**
* only dispatched when you actually
* solve the level, not ask for solution
* or solve it again.
*/
SOLVE_LEVEL: null
}), }),
PayloadSources: keyMirror({ PayloadSources: keyMirror({

View file

@ -34,8 +34,6 @@ var regexMap = {
'objective': /^(objective|assignment)$/ 'objective': /^(objective|assignment)$/
}; };
var MAX_TIMES_SHOW_ANIMATION = 5;
var parse = util.genParseCommand(regexMap, 'processLevelCommand'); var parse = util.genParseCommand(regexMap, 'processLevelCommand');
var Level = Sandbox.extend({ var Level = Sandbox.extend({
@ -439,8 +437,6 @@ var Level = Sandbox.extend({
} }
this.hideGoal(); this.hideGoal();
window.numLevelsSolved = window.numLevelsSolved || 0;
window.numLevelsSolved++;
var nextLevel = LevelStore.getNextLevel(this.level.id); var nextLevel = LevelStore.getNextLevel(this.level.id);
var numCommands = this.gitCommandsIssued.length; var numCommands = this.gitCommandsIssued.length;
@ -448,11 +444,17 @@ var Level = Sandbox.extend({
var skipFinishDialog = this.testOption('noFinishDialog') || var skipFinishDialog = this.testOption('noFinishDialog') ||
this.wasResetAfterSolved; this.wasResetAfterSolved;
var skipFinishAnimation = this.wasResetAfterSolved || var skipFinishAnimation = this.wasResetAfterSolved;
window.numLevelsSolved > MAX_TIMES_SHOW_ANIMATION;
if (!skipFinishAnimation) {
GlobalStateActions.levelSolved();
}
/**
* Speed up the animation each time we see it.
*/
var speed = 1.0; var speed = 1.0;
switch (window.numLevelsSolved) { switch (GlobalStateStore.getNumLevelsSolved()) {
case 2: case 2:
speed = 1.5; speed = 1.5;
break; break;
@ -466,6 +468,9 @@ var Level = Sandbox.extend({
speed = 2.4; speed = 2.4;
break; break;
} }
if (GlobalStateStore.getNumLevelsSolved() > 5) {
speed = 2.5;
}
var finishAnimationChain = null; var finishAnimationChain = null;
if (skipFinishAnimation) { if (skipFinishAnimation) {

View file

@ -10,6 +10,7 @@ var ActionTypes = AppConstants.ActionTypes;
var _isAnimating = false; var _isAnimating = false;
var _flipTreeY = false; var _flipTreeY = false;
var _numLevelsSolved = 0;
var GlobalStateStore = assign( var GlobalStateStore = assign(
{}, {},
@ -24,6 +25,10 @@ AppConstants.StoreSubscribePrototype,
return _flipTreeY; return _flipTreeY;
}, },
getNumLevelsSolved: function() {
return _numLevelsSolved;
},
dispatchToken: AppDispatcher.register(function(payload) { dispatchToken: AppDispatcher.register(function(payload) {
var action = payload.action; var action = payload.action;
var shouldInform = false; var shouldInform = false;
@ -37,6 +42,10 @@ AppConstants.StoreSubscribePrototype,
_flipTreeY = action.flipTreeY; _flipTreeY = action.flipTreeY;
shouldInform = true; shouldInform = true;
break; break;
case ActionTypes.LEVEL_SOLVED:
_numLevelsSolved++;
shouldInform = true;
break;
} }
if (shouldInform) { if (shouldInform) {