Skip to content

Commit

Permalink
Merge pull request OgarProject#65 from krzycho1024/master
Browse files Browse the repository at this point in the history
Split cell when maximum is reached
  • Loading branch information
Ephemerality committed Jul 8, 2015
2 parents 6ebfcea + 7ea18f2 commit e6c1c3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/entity/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ Cell.prototype.getSize = function() {
};

Cell.prototype.addMass = function(n) {
this.mass = Math.min(this.mass + n,this.owner.gameServer.config.playerMaxMass);
if(this.mass + n > this.owner.gameServer.config.playerMaxMass && this.owner.cells.length < this.owner.gameServer.config.playerMaxCells) {
this.mass = (this.mass + n) / 2;
this.owner.gameServer.newCellVirused(this.owner, this, 0, this.mass, 150);
} else {
this.mass = Math.min(this.mass + n,this.owner.gameServer.config.playerMaxMass);
}
};

Cell.prototype.getSpeed = function() {
Expand Down

0 comments on commit e6c1c3e

Please sign in to comment.