mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-23 12:15:50 +02:00
pretty legit level dropdown
This commit is contained in:
parent
0012c3de54
commit
378fcc0377
10 changed files with 542 additions and 28 deletions
|
@ -9,15 +9,21 @@ var sequenceInfo = require('../levels').sequenceInfo;
|
|||
function LevelArbiter() {
|
||||
this.levelMap = {};
|
||||
this.init();
|
||||
// TODO -- local storage sync
|
||||
this.solvedMap = {};
|
||||
}
|
||||
|
||||
LevelArbiter.prototype.init = function() {
|
||||
var previousLevelID;
|
||||
_.each(levelSequences, function(levels, levelSequenceName) {
|
||||
// for this particular sequence...
|
||||
_.each(levels, function(level) {
|
||||
_.each(levels, function(level, index) {
|
||||
this.validateLevel(level);
|
||||
this.levelMap[level.id] = level;
|
||||
this.levelMap[level.id] = _.extend(
|
||||
{},
|
||||
{ index: index },
|
||||
level
|
||||
);
|
||||
|
||||
// build up the chaining between levels
|
||||
if (previousLevelID) {
|
||||
|
@ -28,6 +34,18 @@ LevelArbiter.prototype.init = function() {
|
|||
}, this);
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.getSolvedMap = function() {
|
||||
return this.solvedMap;
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.isLevelSolved = function(id) {
|
||||
if (!this.levelMap[id]) {
|
||||
throw new Error('that level doesnt exist!');
|
||||
}
|
||||
console.log('is it solved', id);
|
||||
return Boolean(this.solvedMap[id]);
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.validateLevel = function(level) {
|
||||
level = level || {};
|
||||
var requiredFields = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue