mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-02 18:54:27 +02:00
fluxify it
This commit is contained in:
parent
78b87b3c47
commit
de8d8221f5
4 changed files with 34 additions and 8 deletions
|
@ -14,6 +14,12 @@ var GlobalStateActions = {
|
|||
});
|
||||
},
|
||||
|
||||
levelSolved: function() {
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.LEVEL_SOLVED,
|
||||
});
|
||||
},
|
||||
|
||||
changeFlipTreeY: function(flipTreeY) {
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.CHANGE_FLIP_TREE_Y,
|
||||
|
|
|
@ -25,7 +25,13 @@ module.exports = {
|
|||
CHANGE_FLIP_TREE_Y: null,
|
||||
SUBMIT_COMMAND: 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({
|
||||
|
|
|
@ -34,8 +34,6 @@ var regexMap = {
|
|||
'objective': /^(objective|assignment)$/
|
||||
};
|
||||
|
||||
var MAX_TIMES_SHOW_ANIMATION = 5;
|
||||
|
||||
var parse = util.genParseCommand(regexMap, 'processLevelCommand');
|
||||
|
||||
var Level = Sandbox.extend({
|
||||
|
@ -439,8 +437,6 @@ var Level = Sandbox.extend({
|
|||
}
|
||||
|
||||
this.hideGoal();
|
||||
window.numLevelsSolved = window.numLevelsSolved || 0;
|
||||
window.numLevelsSolved++;
|
||||
|
||||
var nextLevel = LevelStore.getNextLevel(this.level.id);
|
||||
var numCommands = this.gitCommandsIssued.length;
|
||||
|
@ -448,11 +444,17 @@ var Level = Sandbox.extend({
|
|||
|
||||
var skipFinishDialog = this.testOption('noFinishDialog') ||
|
||||
this.wasResetAfterSolved;
|
||||
var skipFinishAnimation = this.wasResetAfterSolved ||
|
||||
window.numLevelsSolved > MAX_TIMES_SHOW_ANIMATION;
|
||||
var skipFinishAnimation = this.wasResetAfterSolved;
|
||||
|
||||
if (!skipFinishAnimation) {
|
||||
GlobalStateActions.levelSolved();
|
||||
}
|
||||
|
||||
/**
|
||||
* Speed up the animation each time we see it.
|
||||
*/
|
||||
var speed = 1.0;
|
||||
switch (window.numLevelsSolved) {
|
||||
switch (GlobalStateStore.getNumLevelsSolved()) {
|
||||
case 2:
|
||||
speed = 1.5;
|
||||
break;
|
||||
|
@ -466,6 +468,9 @@ var Level = Sandbox.extend({
|
|||
speed = 2.4;
|
||||
break;
|
||||
}
|
||||
if (GlobalStateStore.getNumLevelsSolved() > 5) {
|
||||
speed = 2.5;
|
||||
}
|
||||
|
||||
var finishAnimationChain = null;
|
||||
if (skipFinishAnimation) {
|
||||
|
|
|
@ -10,6 +10,7 @@ var ActionTypes = AppConstants.ActionTypes;
|
|||
|
||||
var _isAnimating = false;
|
||||
var _flipTreeY = false;
|
||||
var _numLevelsSolved = 0;
|
||||
|
||||
var GlobalStateStore = assign(
|
||||
{},
|
||||
|
@ -24,6 +25,10 @@ AppConstants.StoreSubscribePrototype,
|
|||
return _flipTreeY;
|
||||
},
|
||||
|
||||
getNumLevelsSolved: function() {
|
||||
return _numLevelsSolved;
|
||||
},
|
||||
|
||||
dispatchToken: AppDispatcher.register(function(payload) {
|
||||
var action = payload.action;
|
||||
var shouldInform = false;
|
||||
|
@ -37,6 +42,10 @@ AppConstants.StoreSubscribePrototype,
|
|||
_flipTreeY = action.flipTreeY;
|
||||
shouldInform = true;
|
||||
break;
|
||||
case ActionTypes.LEVEL_SOLVED:
|
||||
_numLevelsSolved++;
|
||||
shouldInform = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldInform) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue