Skip to content

Commit

Permalink
Merge pull request #227 from bigfoot90/foodMass-fix
Browse files Browse the repository at this point in the history
[bugfix] Food mass different from 1
  • Loading branch information
igorantun committed Jun 23, 2015
2 parents 22d5980 + c2f1869 commit 1ca6d50
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ function balanceMass() {
.reduce(function(pu,cu) { return pu+cu;}, 0);

if (totalMass < c.gameMass) {
console.log('adding ' + (c.gameMass - totalMass) + ' mass to level');
addFood(c.gameMass - totalMass);
var missingMass = c.gameMass - totalMass;
console.log('adding ' + missingMass + ' mass to level');
addFood(parseInt(missingMass / c.foodMass));
console.log('mass rebalanced');
}
else if (totalMass > c.gameMass) {
console.log('removing ' + (totalMass - c.gameMass) + ' mass from level');
removeFood(totalMass - c.gameMass);
var excessMass = totalMass - c.gameMass;
console.log('removing ' + excessMass + ' mass from level');
removeFood(parseInt(excessMass / c.foodMass));
console.log('mass rebalanced');
}
}
Expand Down

0 comments on commit 1ca6d50

Please sign in to comment.