no more ids on levels, its generated automatically, and index utilization

This commit is contained in:
Peter Cottle 2013-01-09 12:49:40 -08:00
parent a1a6820d77
commit d406317788
10 changed files with 59 additions and 66 deletions

View file

@ -15603,7 +15603,8 @@ LevelArbiter.prototype.validateLevel = function(level) {
var optionalFields = [
'hint',
'disabledMap'
'disabledMap',
'startTree'
];
_.each(requiredFields, function(field) {
@ -16499,6 +16500,7 @@ var Q = require('q');
var util = require('../util');
var Main = require('../app');
var Errors = require('../util/errors');
var Visualization = require('../visuals/visualization').Visualization;
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
@ -16526,11 +16528,9 @@ var parse = util.genParseCommand(regexMap, 'processLevelBuilderCommand');
var LevelBuilder = Level.extend({
initialize: function(options) {
options = options || {};
options.level = options.level || {};
this.options = options;
this.level = {};
this.level.startDialog = {
options.level.startDialog = {
childViews: [{
type: 'ModalAlert',
options: {
@ -16539,10 +16539,10 @@ var LevelBuilder = Level.extend({
'',
'Here are the main steps:',
'',
' * Define the starting tree',
' * Enter the series of git commands that compose of the (optimal) solution',
' * Define the goal tree, which also defines the solution',
' * Enter the command ```finish building``` to specify start dialogs and such'
' * Define the starting tree with ```define start```',
' * Enter the series of git commands that compose the (optimal) solution',
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
' * Enter the command ```finish``` to output your level JSON!'
]
}
}]
@ -16709,13 +16709,20 @@ var LevelBuilder = Level.extend({
},
finish: function(command, deferred) {
if (!this.level.id) {
this.setID();
if (!this.gitCommandsIssued.length) {
command.set('error', new Errors.GitError({
msg: 'Your solution is empty!'
}));
deferred.resolve();
return;
}
if (this.level.hint === undefined) {
this.setHint();
}
console.log(this.level, this.startTree);
console.log(this.level);
command.finishWith(deferred);
},
processLevelBuilderCommand: function(command, deferred) {
@ -19313,7 +19320,8 @@ LevelArbiter.prototype.validateLevel = function(level) {
var optionalFields = [
'hint',
'disabledMap'
'disabledMap',
'startTree'
];
_.each(requiredFields, function(field) {
@ -19373,6 +19381,7 @@ var Q = require('q');
var util = require('../util');
var Main = require('../app');
var Errors = require('../util/errors');
var Visualization = require('../visuals/visualization').Visualization;
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
@ -19400,11 +19409,9 @@ var parse = util.genParseCommand(regexMap, 'processLevelBuilderCommand');
var LevelBuilder = Level.extend({
initialize: function(options) {
options = options || {};
options.level = options.level || {};
this.options = options;
this.level = {};
this.level.startDialog = {
options.level.startDialog = {
childViews: [{
type: 'ModalAlert',
options: {
@ -19413,10 +19420,10 @@ var LevelBuilder = Level.extend({
'',
'Here are the main steps:',
'',
' * Define the starting tree',
' * Enter the series of git commands that compose of the (optimal) solution',
' * Define the goal tree, which also defines the solution',
' * Enter the command ```finish building``` to specify start dialogs and such'
' * Define the starting tree with ```define start```',
' * Enter the series of git commands that compose the (optimal) solution',
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
' * Enter the command ```finish``` to output your level JSON!'
]
}
}]
@ -19583,13 +19590,20 @@ var LevelBuilder = Level.extend({
},
finish: function(command, deferred) {
if (!this.level.id) {
this.setID();
if (!this.gitCommandsIssued.length) {
command.set('error', new Errors.GitError({
msg: 'Your solution is empty!'
}));
deferred.resolve();
return;
}
if (this.level.hint === undefined) {
this.setHint();
}
console.log(this.level, this.startTree);
console.log(this.level);
command.finishWith(deferred);
},
processLevelBuilderCommand: function(command, deferred) {

View file

@ -32,8 +32,11 @@ LevelArbiter.prototype.init = function() {
this.validateLevel(level);
this.levelMap[level.id] = _.extend(
{},
{ index: index },
level
level,
{
index: index,
id: levelSequenceName + String(index)
}
);
// build up the chaining between levels
@ -68,7 +71,6 @@ LevelArbiter.prototype.syncToStorage = function() {
LevelArbiter.prototype.validateLevel = function(level) {
level = level || {};
var requiredFields = [
'id',
'name',
'goalTreeString',
'solutionCommand'

View file

@ -4,6 +4,7 @@ var Q = require('q');
var util = require('../util');
var Main = require('../app');
var Errors = require('../util/errors');
var Visualization = require('../visuals/visualization').Visualization;
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
@ -23,6 +24,7 @@ var regexMap = {
'define start': /^define start$/,
'show start': /^show start$/,
'hide start': /^hide start$/,
'define hint': /^define hint$/,
'finish': /^finish$/
};
@ -31,11 +33,9 @@ var parse = util.genParseCommand(regexMap, 'processLevelBuilderCommand');
var LevelBuilder = Level.extend({
initialize: function(options) {
options = options || {};
options.level = options.level || {};
this.options = options;
this.level = {};
this.level.startDialog = {
options.level.startDialog = {
childViews: [{
type: 'ModalAlert',
options: {
@ -44,10 +44,11 @@ var LevelBuilder = Level.extend({
'',
'Here are the main steps:',
'',
' * Define the starting tree',
' * Enter the series of git commands that compose of the (optimal) solution',
' * Define the goal tree, which also defines the solution',
' * Enter the command ```finish building``` to specify start dialogs and such'
' * Define the starting tree with ```define start```',
' * Enter the series of git commands that compose the (optimal) solution',
' * Define the goal tree with ```define goal```. Defining the goal also defines the solution',
' * Optionally define a hint with ```define hint```',
' * Enter the command ```finish``` to output your level JSON!'
]
}
}]
@ -198,33 +199,20 @@ var LevelBuilder = Level.extend({
this.showGoal(command, deferred);
},
setHint: function(command, deferred) {
defineHint: function(command, deferred) {
this.level.hint = prompt('Enter a hint! Or blank if you dont want one');
if (command) { command.finishWith(deferred); }
},
setID: function(command, deferred) {
var id = prompt('Enter an ID');
while (!id || !id.length) {
id = prompt('Enter an ID... really this time');
}
this.level.id = id;
if (command) { command.finishWith(deferred); }
},
finish: function(command, deferred) {
if (!this.gitCommandsIssued.length) {
command.set('error', new GitError({
command.set('error', new Errors.GitError({
msg: 'Your solution is empty!'
});
}));
deferred.resolve();
return;
}
if (!this.level.id) {
this.setID();
}
if (this.level.hint === undefined) {
this.setHint();
}
@ -239,7 +227,8 @@ var LevelBuilder = Level.extend({
'define start': this.defineStart,
'show start': this.showStart,
'hide start': this.hideStart,
'finish': this.finish
'finish': this.finish,
'define hint': this.defineHint
};
methodMap[command.get('method')].apply(this, arguments);

View file

@ -161,14 +161,7 @@ var LevelDropdownView = ContainedBase.extend({
},
getIndexForID: function(id) {
var index;
var levels = this.sequenceToLevels[this.selectedSequence];
_.each(levels, function(level, _index) {
if (level.id == id) {
index = _index;
}
});
return index;
return Main.getLevelArbiter().getLevel(id).index;
},
selectFirst: function() {

View file

@ -1,5 +1,4 @@
exports.level = {
id: 'intro1',
name: 'Introduction #1',
startDialog: {
childViews: [{

View file

@ -1,5 +1,4 @@
exports.level = {
id: 'intro2',
name: 'Introduction #1',
goalTreeString: '{"branches":{"master":{"target":"C1","id":"master"},"win":{"target":"C2","id":"win"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"win","id":"HEAD"}}',
solutionCommand: 'git checkout -b win; git commit',

View file

@ -1,5 +1,4 @@
exports.level = {
id: 'rebase1',
name: 'Introduction #1',
goalTreeString: '{"branches":{"master":{"target":"C1","id":"master"},"win":{"target":"C2","id":"win"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"win","id":"HEAD"}}',
solutionCommand: 'git checkout -b win; git commit',

View file

@ -1,5 +1,4 @@
exports.level = {
id: 'rebase2',
name: 'Introduction #1',
goalTreeString: '{"branches":{"master":{"target":"C1","id":"master"},"win":{"target":"C2","id":"win"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"win","id":"HEAD"}}',
solutionCommand: 'git checkout -b win; git commit',

View file

@ -1,5 +1,4 @@
exports.level = {
id: 'rebase3',
name: 'Introduction #1',
goalTreeString: '{"branches":{"master":{"target":"C1","id":"master"},"win":{"target":"C2","id":"win"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"win","id":"HEAD"}}',
solutionCommand: 'git checkout -b win; git commit',

View file

@ -1,6 +1,5 @@
Big Things
~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] level builder finish
[ ] level builder dialog tester
[ ] level builder dialog builder
@ -32,6 +31,7 @@ Ideas for cleaning
Done things:
(I only started this on Dec 17th 2012 to get a better sense of what was done)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[x] level builder finish
[x] level builder? :OOO
* basically just an extension of level (or sandbox), that has commands like
```save tree beginning``` or ```save tree goal``` and then a final