mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
Objective and Assignment commands Issue #76 works even in level builder
This commit is contained in:
parent
63a8d385bf
commit
e081c47e31
8 changed files with 154 additions and 28 deletions
|
@ -29,7 +29,8 @@ var regexMap = {
|
|||
'start dialog': /^start dialog$/,
|
||||
'show goal': /^(show goal|goal|help goal)$/,
|
||||
'hide goal': /^hide goal$/,
|
||||
'show solution': /^show solution($|\s)/
|
||||
'show solution': /^show solution($|\s)/,
|
||||
'objective': /^(objective|assignment)$/
|
||||
};
|
||||
|
||||
var parse = util.genParseCommand(regexMap, 'processLevelCommand');
|
||||
|
@ -77,6 +78,31 @@ var Level = Sandbox.extend({
|
|||
}, this.getAnimationTime() * 1.2);
|
||||
},
|
||||
|
||||
objectiveDialog: function(command, deferred, levelObj) {
|
||||
levelObj = (levelObj === undefined) ? this.level : levelObj;
|
||||
|
||||
if (!levelObj || !levelObj.startDialog) {
|
||||
command.set('error', new Errors.GitError({
|
||||
msg: intl.str('no-start-dialog')
|
||||
}));
|
||||
deferred.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = _.clone(intl.getStartDialog(levelObj));
|
||||
// grab the last slide only
|
||||
dialog.childViews = dialog.childViews.splice(-1);
|
||||
new MultiView(_.extend(
|
||||
dialog,
|
||||
{ deferred: deferred }
|
||||
));
|
||||
|
||||
// when its closed we are done
|
||||
deferred.promise.then(function() {
|
||||
command.set('status', 'finished');
|
||||
});
|
||||
},
|
||||
|
||||
startDialog: function(command, deferred) {
|
||||
if (!this.level.startDialog) {
|
||||
command.set('error', new Errors.GitError({
|
||||
|
@ -494,7 +520,8 @@ var Level = Sandbox.extend({
|
|||
'hide goal': this.hideGoal,
|
||||
'show solution': this.showSolution,
|
||||
'start dialog': this.startDialog,
|
||||
'help level': this.startDialog
|
||||
'help level': this.startDialog,
|
||||
'objective': this.objectiveDialog
|
||||
};
|
||||
var method = methodMap[command.get('method')];
|
||||
if (!method) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue