mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-05 17:30:44 +08:00
Progress #3
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var Entity = require('../entities/entity');
|
||||
|
||||
exports = module.exports = EntityController;
|
||||
|
||||
function EntityController () {
|
||||
@@ -6,7 +8,21 @@ function EntityController () {
|
||||
|
||||
EntityController.prototype = {
|
||||
add: function (id) {
|
||||
|
||||
var newEntity, entityFound = false;
|
||||
|
||||
this.entities.some(function (entity) {
|
||||
if (entity.id === id) {
|
||||
newEntity = entity;
|
||||
entityFound = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!entityFound) {
|
||||
newEntity = new Entity(id);
|
||||
this.entities.push(newEntity);
|
||||
}
|
||||
return newEntity;
|
||||
},
|
||||
remove: function (id) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user