impact-worldmaster
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "./src/server", | ||
@@ -17,0 +17,0 @@ "scripts": { |
@@ -1,6 +0,6 @@ | ||
ig.module( 'game.levels.turd' ) | ||
.requires( 'impact.image' ) | ||
ig.module( 'game.levels.test' ) | ||
.requires( 'impact.image','game.entities.example' ) | ||
.defines(function(){ | ||
LevelTurd=/*JSON[*/{"entities":[],"layer":[{"name":"new_layer_0","width":30,"height":20,"linkWithCollision":false,"visible":true,"tilesetName":"/media/tilemaps/240x8c3.jpg","repeat":false,"preRender":false,"distance":"1","tilesize":32,"foreground":false,"data":[[97,98,98,98,98,98,98,114,114,114,114,130,130,130,114,114,114,114,114,114,114,98,98,98,98,98,98,98,98,98],[97,98,114,130,129,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,114,114,114,114,114],[97,98,130,130,114,129,129,130,129,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,130],[130,129,113,130,130,114,114,130,114,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,130],[130,114,129,129,130,130,130,130,130,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,130],[130,130,114,113,113,113,113,163,164,163,164,163,164,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[129,130,130,129,129,129,129,179,180,179,180,179,180,179,180,113,163,164,113,113,113,113,113,113,113,97,97,97,97,130],[113,113,113,97,97,97,97,163,164,129,129,129,129,129,129,129,179,180,129,129,129,129,129,129,129,113,113,113,113,130],[129,129,129,129,129,129,65,179,180,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,130],[97,97,97,97,97,65,82,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[98,113,49,97,50,82,98,179,180,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,97,97,130],[98,129,129,113,97,97,97,163,164,129,49,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,130],[98,129,130,129,113,113,113,179,180,97,97,97,97,97,97,97,97,97,97,129,130,130,130,129,129,129,129,129,129,98],[98,129,130,114,129,49,129,163,164,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,113,113,113,114],[98,129,130,130,114,114,114,179,180,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,129,129,129,129,129,130],[97,97,129,130,130,130,130,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[113,113,113,113,113,113,113,179,180,113,113,113,113,113,113,113,113,113,97,97,97,97,97,97,97,97,97,97,129,130],[129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,113,113,113,113,129,130],[97,97,97,97,97,97,97,97,97,97,97,97,97,97,129,130,130,130,129,129,129,129,129,129,129,129,129,129,129,130],[113,113,113,113,113,113,113,113,113,113,113,113,113,113,129,129,129,129,129,129,129,129,130,130,130,130,130,114,114,130]]}]}/*]JSON*/; | ||
LevelTurdResources=[new ig.Image('/media/tilemaps/240x8c3.jpg')]; | ||
LevelTest=/*JSON[*/{"entities":[{"type":"EntityExample","x":344,"y":276}],"layer":[{"name":"new_layer_0","width":30,"height":20,"linkWithCollision":false,"visible":1,"tilesetName":"/media/tilemaps/240x8c3.jpg","repeat":false,"preRender":false,"distance":"1","tilesize":32,"foreground":false,"data":[[97,98,98,98,98,98,98,114,114,114,114,130,130,130,114,114,114,114,114,114,114,98,98,98,98,98,98,98,98,98],[97,98,114,130,129,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,114,114,114,114,114],[97,98,130,130,114,129,129,130,129,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,130],[130,129,113,130,130,114,114,130,114,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,130],[130,114,129,129,130,130,130,130,130,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,130],[130,130,114,113,113,113,113,163,164,163,164,163,164,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[129,130,130,129,129,129,129,179,180,179,180,179,180,179,180,113,163,164,113,113,113,113,113,113,113,97,97,97,97,130],[113,113,113,97,97,97,97,163,164,129,129,129,129,129,129,129,179,180,129,129,129,129,129,129,129,113,113,113,113,130],[129,129,129,129,129,129,65,179,180,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,130],[97,97,97,97,97,65,82,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[98,113,49,97,50,82,98,179,180,113,113,113,113,113,113,113,113,113,113,113,113,113,113,97,97,97,97,97,97,130],[98,129,129,113,97,97,97,163,164,129,49,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,130],[98,129,130,129,113,113,113,179,180,97,97,97,97,97,97,97,97,97,97,129,130,130,130,129,129,129,129,129,129,98],[98,129,130,114,129,49,129,163,164,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,113,113,113,114],[98,129,130,130,114,114,114,179,180,114,114,114,114,114,114,114,114,114,114,114,129,129,129,129,129,129,129,129,129,130],[97,97,129,130,130,130,130,163,164,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130],[113,113,113,113,113,113,113,179,180,113,113,113,113,113,113,113,113,113,97,97,97,97,97,97,97,97,97,97,129,130],[129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,113,113,113,113,113,113,113,113,113,113,129,130],[97,97,97,97,97,97,97,97,97,97,97,97,97,97,129,130,130,130,129,129,129,129,129,129,129,129,129,129,129,130],[113,113,113,113,113,113,113,113,113,113,113,113,113,113,129,129,129,129,129,129,129,129,130,130,130,130,130,114,114,130]]}]}/*]JSON*/; | ||
LevelTestResources=[new ig.Image('/media/tilemaps/240x8c3.jpg')]; | ||
}); |
var fs = require('fs'), | ||
path = require('path'), | ||
glob = require('glob'); | ||
path = require('path'), | ||
glob = require('glob'); | ||
function listen(server, opts) { | ||
var options = opts || {}; | ||
var root = opts.root || __dirname; | ||
var options = opts || {}; | ||
var root = opts.root || __dirname; | ||
function getGlob(req, res) { | ||
function getGlob(req, res) { | ||
function handleGlob(er, matches) { | ||
for (var i in matches) { | ||
matches[i] = matches[i].substring(root.length); | ||
} | ||
var lib = root + '/lib/', | ||
globPattern = root + '/' + req.param('glob'); | ||
res.send(matches); | ||
} | ||
function handleGlob(er, matches) { | ||
for (var i in matches) { | ||
matches[i] = matches[i].substring(lib.length); | ||
} | ||
res.send(matches); | ||
} | ||
glob(root + req.param('glob'), 0, handleGlob); | ||
} | ||
glob(globPattern, 0, handleGlob); | ||
} | ||
function save(req, res) { | ||
var _path = req.body.path, | ||
_data = req.body.data; | ||
var errorWrite = { | ||
error: 2, | ||
msg: 'Couldn\'t write to file: ' + _path | ||
}, | ||
errorGeneric = { | ||
error: 0 | ||
}, | ||
errorNoSuffix = { | ||
error: 3, | ||
msg: 'File must have a .js suffix' | ||
}, | ||
errorNoData = { | ||
error: 1, | ||
msg: 'No Data or Path specified' | ||
}; | ||
function save(req, res) { | ||
var _path = req.body.path, | ||
_data = req.body.data; | ||
function saveFile(err) { | ||
if (err) { | ||
res.send(errorWrite); | ||
} else { | ||
res.send(errorGeneric); | ||
} | ||
} | ||
var errorWrite = { | ||
error: 2, | ||
msg: 'Couldn\'t write to file: ' + _path | ||
}, | ||
errorGeneric = { | ||
error: 0 | ||
}, | ||
errorNoSuffix = { | ||
error: 3, | ||
msg: 'File must have a .js suffix' | ||
}, | ||
errorNoData = { | ||
error: 1, | ||
msg: 'No Data or Path specified' | ||
}; | ||
if (_path && _data) { | ||
if (/\.js$/.test(_path)) { | ||
fs.writeFile(path.join(root, _path), _data, saveFile); | ||
} else { | ||
res.send(errorNoSuffix); | ||
} | ||
} else { | ||
res.send(errorNoData); | ||
} | ||
} | ||
function saveFile(err) { | ||
if (err) { | ||
res.send(errorWrite); | ||
} else { | ||
res.send(errorGeneric); | ||
} | ||
} | ||
if (_path && _data) { | ||
if (/\.js$/.test(_path)) { | ||
function browse(req, res) { | ||
var dir = req.param('dir') || '', | ||
type = req.param('type'), | ||
dirpath, | ||
stats, | ||
filter, | ||
file, | ||
listItem, | ||
types = { | ||
scripts: ['.js'], | ||
images: ['.png', '.gif', '.jpg', '.jpeg'] | ||
}, | ||
result = { | ||
parent: false, | ||
dirs: [], | ||
files: [] | ||
}; | ||
fs.writeFile(path.join(root, _path), _data, saveFile); | ||
} else { | ||
res.send(errorNoSuffix); | ||
} | ||
} else { | ||
res.send(errorNoData); | ||
} | ||
} | ||
filter = (type && types[type]) ? | ||
types[type] : | ||
false; | ||
result.parent = req.param('dir') ? | ||
dir.substring(0, dir.lastIndexOf('/')) : | ||
false; | ||
function browse(req, res) { | ||
var dir = req.param('dir') || '', | ||
type = req.param('type'), | ||
dirpath, | ||
stats, | ||
filter, | ||
file, | ||
listItem, | ||
types = { | ||
scripts: ['.js'], | ||
images: ['.png', '.gif', '.jpg', '.jpeg'] | ||
}, | ||
result = { | ||
parent: false, | ||
dirs: [], | ||
files: [] | ||
}; | ||
dir = (dir[dir.length-1] === '/') ? | ||
dir : | ||
dir += '/'; | ||
filter = (type && types[type]) ? | ||
types[type] : | ||
false; | ||
dirpath = path.normalize(root + '\\' + dir); | ||
result.parent = req.param('dir') ? | ||
dir.substring(0, dir.lastIndexOf('/')) : | ||
false; | ||
function walkDirectory(err, files) { | ||
for (var i in files) { | ||
dir = (dir[dir.length - 1] === '/') ? | ||
dir : | ||
dir += '/'; | ||
file = files[i]; | ||
listItem = dir + file; | ||
stats = fs.statSync(path.join(dirpath, file)); | ||
dirpath = path.normalize(root + '\\' + dir); | ||
if (stats.isDirectory()) { | ||
result.dirs.push(listItem); | ||
} else if (stats.isFile()) { | ||
result.files.push(listItem); | ||
} | ||
} | ||
res.send(result); | ||
} | ||
function walkDirectory(err, files) { | ||
for (var i in files) { | ||
fs.readdir(dirpath, walkDirectory); | ||
} | ||
file = files[i]; | ||
listItem = dir + file; | ||
stats = fs.statSync(path.join(dirpath, file)); | ||
server.get('/worldmaster/glob', getGlob); | ||
server.post('/worldmaster/save', save); | ||
server.get('/worldmaster/browse', browse); | ||
if (stats.isDirectory()) { | ||
result.dirs.push(listItem); | ||
return { | ||
root: root | ||
}; | ||
} else if (stats.isFile()) { | ||
result.files.push(listItem); | ||
} | ||
} | ||
res.send(result); | ||
} | ||
fs.readdir(dirpath, walkDirectory); | ||
} | ||
server.get('/worldmaster/glob', getGlob); | ||
server.post('/worldmaster/save', save); | ||
server.get('/worldmaster/browse', browse); | ||
return { | ||
root: root | ||
}; | ||
} | ||
exports.listen = listen; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
575808
19
1272