Skip to content

Commit

Permalink
Sending a brandy message!
Browse files Browse the repository at this point in the history
  • Loading branch information
mckk committed Jun 20, 2011
1 parent 7012e33 commit 2e0b584
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions game/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Player.prototype.buy = function(what) {
return this.buyCapacity();
else if(what == "strawberries")
return this.buyStrawberries();
else if(what == "brandy")
return this.buyBrandy();
else
return false;
}
Expand All @@ -93,6 +95,20 @@ Player.prototype.buyCapacity = function() {
}
}

Player.prototype.buyBrandy = function() {
if(this.getResource("gold") >= 1000) {
this.updateResource("decrease", "gold", 1000);
this.sendResourceUpdate();
this.client.send({
type: 'brandy'
});
this.brandy = true;
return true;
} else {
return false;
}
}

Player.prototype.buyStrawberries = function() {
return true;
}
Expand All @@ -104,6 +120,10 @@ Player.prototype.connectSocket = function(client) {
type: 'newArrival',
player: this.getBasicData()
});
if(this.brandy !== undefined)
this.client.send({
type: 'brandy'
});
}

Player.prototype.disconnectSocket = function() {
Expand Down

0 comments on commit 2e0b584

Please sign in to comment.