work in progress... worked on channel attributes and game goal. fixes #45 and references #48

This commit is contained in:
logsol 2014-03-30 00:12:04 +01:00
parent 039213cf50
commit 55256ada95
23 changed files with 409 additions and 110 deletions

View file

@ -104,6 +104,9 @@ function (Exception) {
level: {
reset: null
}
},
round: {
end: null
}
},
engine: {
@ -128,6 +131,9 @@ function (Exception) {
},
gameCommand: {
broadcast: null
},
controlCommand: {
broadcast: null
}
}
}

View file

@ -7,7 +7,7 @@ function (Settings) {
var requestAnimFrame = (function () {
var _setTimeout = function ( callback ) {
setTimeout(callback, Settings.BOX2D_TIME_STEP * 1000);
return setTimeout(callback, Settings.BOX2D_TIME_STEP * 1000);
}
if (typeof window != 'undefined') {

View file

@ -0,0 +1,61 @@
define([
],
function () {
function validate(object, description) {
if(description.optional && (object === null || object === "")) {
return true;
}
if(object === null) {
return false;
}
if(typeof object === 'undefined') {
return false;
}
if(typeof object === 'NaN') {
return false;
}
if(description.type == 'array' && !(object instanceof Array)) {
return false;
}
if(description.type != 'array' && typeof object != description.type) {
return false;
}
if(description.max && object > description.max) {
return false;
}
if(description.min && object < description.min) {
return false;
}
if(description.maxLength && object.length > description.maxLength) {
return false;
}
if(description.minLength && object.length < description.minLength) {
return false;
}
if(description.in && description.in.indexOf(object) === -1) {
return false;
}
if(description.regex && !description.regex.test(object)) {
return false;
}
return true;
}
return validate;
});