Code cleanup

This commit is contained in:
Jeremiah Billmann
2013-07-14 14:35:15 -04:00
parent bbaf13baab
commit 0883042510
2 changed files with 14 additions and 17 deletions
+8 -8
View File
@@ -105,10 +105,18 @@ GarageServer.prototype.getPlayers = function () {
return this.game.getPlayers();
};
GarageServer.prototype.getEntities = function () {
return this.game.getEntities();
};
GarageServer.prototype.updatePlayerState = function (id, state) {
this.game.updatePlayerState(id, state);
};
GarageServer.prototype.updateEntityState = function (id, state) {
this.game.updateEntityState(id, state);
};
GarageServer.prototype.addEntity = function (id, state) {
this.game.addEntity(id, state);
};
@@ -117,14 +125,6 @@ GarageServer.prototype.removeEntity = function (id) {
this.game.removeEntity(id);
};
GarageServer.prototype.updateEntityState = function (id, state) {
this.game.updateEntityState(id, state);
};
GarageServer.prototype.getEntities = function () {
return this.game.getEntities();
};
exports.createGarageServer = function (io, options) {
return new GarageServer(io, options);
};
+6 -9
View File
@@ -64,20 +64,17 @@ GarageServerGame.prototype.getPlayer = function (id) {
};
GarageServerGame.prototype.updatePlayerState = function (id, state) {
var currentTime = new Date().getTime() - this.startTime;
this.playerController.entities.some(function (player) {
if (player.id === id) {
player.addState(state, currentTime);
return true;
}
});
this.updateState(this.playerController, id, state);
};
GarageServerGame.prototype.updateEntityState = function (id, state) {
this.updateState(this.entityController, id, state);
};
GarageServerGame.prototype.updateState = function (controller, id, state) {
var currentTime = new Date().getTime() - this.startTime;
this.entityController.entities.some(function (entity) {
controller.entities.some(function (entity) {
if (entity.id === id) {
entity.addState(state, currentTime);
return true;