Skip to content

Commit

Permalink
Fix issues with powerup icons. Powerup logic moved to socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkaina committed Dec 9, 2013
1 parent cd27c0c commit 2022a9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 0 additions & 6 deletions config/socket/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ Player.prototype.usePowerUp = function(powerUpData) {
if (this.powerUps[powerUpData.name]){
this.powerUps[powerUpData.name]--;
this[powerUpData.name] = true;
powerUp = {powerUpName:powerUpData.name, playerName:that.name};
that.io.sockets.in(that.game).emit('powerUpUsed', powerUp);
setTimeout(function(){
that[powerUpData.name] = false;
that.io.sockets.in(that.game).emit('powerUpExpired', powerUp);
}, that.powerUpDuration);
}
};

Expand Down
7 changes: 6 additions & 1 deletion config/socket/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(io){
var _allGames = {};
var _id = 1;

var _maxPlayers = 1;
var _maxPlayers = 2;

io.sockets.on('connection', function(socket){

Expand Down Expand Up @@ -130,6 +130,11 @@ module.exports = function(io){
var game = _allGames[data.gameID];
var player = game.getPlayer(data.playerName);
player.usePowerUp({powerUpID:data.powerUpID, powerUpName:data.powerUpName});
io.sockets.in(data.gameID).emit('powerUpUsed', data);
setTimeout(function(){
player[data.name] = false;
io.sockets.in(data.gameID).emit('powerUpExpired', data);
}, player.powerUpDuration);
});

socket.on('leaveGame', function(data){
Expand Down

0 comments on commit 2022a9e

Please sign in to comment.