awesome level delegation going

This commit is contained in:
Peter Cottle 2013-01-05 16:00:03 -08:00
parent eb33897a22
commit 4b3e13b0b5
5 changed files with 54 additions and 27 deletions

View file

@ -3,8 +3,7 @@ var _ = require('underscore');
var regexMap = {
'show goal': /^show goal$/,
'hide goal': /^hide goal$/,
'show solution': /^show solution$/,
'exit level': /^exit level$/
'show solution': /^show solution$/
};
var parse = function(str) {

View file

@ -345,8 +345,7 @@ var Level = Sandbox.extend({
var methodMap = {
'show goal': this.showGoal,
'hide goal': this.hideGoal,
'show solution': this.showSolution,
'exit level': this.exitLevel
'show solution': this.showSolution
};
var method = methodMap[command.get('method')];
if (!method) {

View file

@ -115,12 +115,21 @@ var Sandbox = Backbone.View.extend({
}, this);
},
exitLevel: function(command, deferred) {
command.addWarning(
"You aren't in a level! You are in a sandbox, start a level with `start level [id]`"
);
deferred.resolve();
},
processSandboxCommand: function(command, deferred) {
var commandMap = {
help: this.helpDialog,
reset: this.reset,
delay: this.delay,
clear: this.clear
'help': this.helpDialog,
'reset': this.reset,
'delay': this.delay,
'clear': this.clear,
'exit level': this.exitLevel,
'start level': this.startLevel
};
var method = commandMap[command.get('method')];
if (!method) { throw new Error('no method for that wut'); }

View file

@ -40,7 +40,9 @@ var regexMap = {
'help': /^help($|\s)|\?/,
'reset': /^reset($|\s)/,
'delay': /^delay (\d+)$/,
'clear': /^clear($|\s)/
'clear': /^clear($|\s)/,
'exit level': /^exit level($|\s)/,
'start level': /^start level ([a-zA-Z0-9]+)/
};
var parse = function(str) {