Skip to content

Commit

Permalink
Merge pull request #209 from enb/issue-208
Browse files Browse the repository at this point in the history
Got rid of scheme builders
  • Loading branch information
blond committed Mar 30, 2016
2 parents d62cb0c + e9aa853 commit b055ad1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 173 deletions.
99 changes: 0 additions & 99 deletions lib/levels/level-builder.js

This file was deleted.

50 changes: 0 additions & 50 deletions lib/levels/level-plain.js

This file was deleted.

34 changes: 12 additions & 22 deletions lib/levels/level.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
var inherit = require('inherit'),
fs = require('fs'),
vow = require('vow'),
path = require('path'),
LevelBuilder = require('./level-builder');
path = require('path');

module.exports = inherit(/** @lends Level.prototype */{
/**
* @constructs Level
* @classdesc Model of level.
*
* @param {String} levelPath — path to level.
* @param {Function} [schemeBuilder]
*/
__constructor: function (levelPath, schemeBuilder) {
__constructor: function (levelPath) {
this._path = levelPath;
this.blocks = {};
this._loadDeferred = vow.defer();
this._schemeBuilder = schemeBuilder;
},

/**
Expand Down Expand Up @@ -200,23 +197,16 @@ module.exports = inherit(/** @lends Level.prototype */{
return promise;
}

var _this = this;
if (this._schemeBuilder) {
var levelBuilder = new LevelBuilder();
vow.when(this._schemeBuilder.buildLevel(this._path, levelBuilder)).then(function () {
_this.blocks = levelBuilder.getBlocks();
deferred.resolve(_this);
});
} else {
var levelPath = this._path;
filterFiles(fs.readdirSync(levelPath)).forEach(function (blockDir) {
var blockDirPath = path.join(levelPath, blockDir);
if (fs.statSync(blockDirPath).isDirectory()) {
_this._loadElement(null, blockDir, blockDirPath, true);
}
});
deferred.resolve(this);
}
var _this = this,
levelPath = this._path;

filterFiles(fs.readdirSync(levelPath)).forEach(function (blockDir) {
var blockDirPath = path.join(levelPath, blockDir);
if (fs.statSync(blockDirPath).isDirectory()) {
_this._loadElement(null, blockDir, blockDirPath, true);
}
});
deferred.resolve(this);

return promise;
}
Expand Down
4 changes: 2 additions & 2 deletions techs/levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = inherit(BaseTech, {
}
levelsIndex[levelPath] = true;
if (!this.node.buildState[levelKey]) {
var level = new Level(levelPath, this.node.getLevelNamingScheme(levelPath));
var level = new Level(levelPath);
if (levelInfo.check === false) {
var blocks = cache.get(levelPath);
if (blocks) {
Expand All @@ -103,7 +103,7 @@ module.exports = inherit(BaseTech, {
var sublevelPath = _this.node.resolvePath(path);
if (!levelsIndex[sublevelPath]) {
levelsIndex[sublevelPath] = true;
levelList.push(new Level(sublevelPath, _this.node.getLevelNamingScheme(sublevelPath)));
levelList.push(new Level(sublevelPath));
}
}));
})
Expand Down

0 comments on commit b055ad1

Please sign in to comment.