mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
new demo command
This commit is contained in:
parent
0cb6e43549
commit
22605249ce
3 changed files with 81 additions and 36 deletions
|
@ -27,7 +27,7 @@ var regexMap = {
|
|||
'start dialog': /^start dialog$/,
|
||||
'show goal': /^show goal$/,
|
||||
'hide goal': /^hide goal$/,
|
||||
'show solution': /^show solution$/
|
||||
'show solution': /^show solution($|\s)/
|
||||
};
|
||||
|
||||
var parse = util.genParseCommand(regexMap, 'processLevelCommand');
|
||||
|
@ -153,6 +153,25 @@ var Level = Sandbox.extend({
|
|||
},
|
||||
|
||||
showSolution: function(command, deferred) {
|
||||
var toIssue = this.level.solutionCommand;
|
||||
var issueFunc = function() {
|
||||
Main.getEventBaton().trigger(
|
||||
'commandSubmitted',
|
||||
toIssue
|
||||
);
|
||||
};
|
||||
|
||||
var commandStr = command.get('rawStr');
|
||||
if (!this.testOptionOnString(commandStr, 'noReset')) {
|
||||
toIssue = 'reset; ' + toIssue;
|
||||
}
|
||||
if (this.testOptionOnString(commandStr, 'force')) {
|
||||
issueFunc();
|
||||
command.finishWith(deferred);
|
||||
return;
|
||||
}
|
||||
|
||||
// allow them for force the solution
|
||||
var confirmDefer = Q.defer();
|
||||
var confirmView = new ConfirmCancelTerminal({
|
||||
markdowns: [
|
||||
|
@ -164,15 +183,7 @@ var Level = Sandbox.extend({
|
|||
});
|
||||
|
||||
confirmDefer.promise
|
||||
.then(_.bind(function() {
|
||||
// ok great add the solution command
|
||||
Main.getEventBaton().trigger(
|
||||
'commandSubmitted',
|
||||
'reset;' + this.level.solutionCommand
|
||||
);
|
||||
this.hideGoal();
|
||||
command.setResult('Solution command added to the command queue...');
|
||||
}, this))
|
||||
.then(issueFunc)
|
||||
.fail(function() {
|
||||
command.setResult("Great! I'll let you get back to it");
|
||||
})
|
||||
|
@ -307,6 +318,10 @@ var Level = Sandbox.extend({
|
|||
return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr'));
|
||||
},
|
||||
|
||||
testOptionOnString: function(str, option) {
|
||||
return str && new RegExp('--' + option).test(str);
|
||||
},
|
||||
|
||||
levelSolved: function(defer) {
|
||||
this.solved = true;
|
||||
Main.getEvents().trigger('levelSolved', this.level.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue