|
@@ -61,8 +61,9 @@ var initMassLog = util.log(c.defaultPlayerMass, c.slowBase);
|
|
|
app.use(express.static(__dirname + '/../client'));
|
|
|
|
|
|
function addFood(toAdd) {
|
|
|
- var radius = util.massToRadius(c.foodMass);
|
|
|
while (toAdd--) {
|
|
|
+ var mass = util.randomInRange(c.foodMass.from,c.foodMass.to);
|
|
|
+ var radius = util.massToRadius(mass);
|
|
|
var position = c.foodUniformDisposition ? util.uniformPosition(food, radius) : util.randomPosition(radius);
|
|
|
food.push({
|
|
|
// Make IDs unique.
|
|
@@ -70,7 +71,7 @@ function addFood(toAdd) {
|
|
|
x: position.x,
|
|
|
y: position.y,
|
|
|
radius: radius,
|
|
|
- mass: c.foodMass,
|
|
|
+ mass: mass,
|
|
|
hue: Math.round(Math.random() * 360)
|
|
|
});
|
|
|
}
|
|
@@ -111,7 +112,7 @@ function mothercellAddFood(mCell,toAdd,limit=true) {
|
|
|
return thisFood.for == this.id;
|
|
|
},mCell).length;
|
|
|
if(!limit || currentCells+toAdd <= c.mothercell.foodLimit) {
|
|
|
- var radius = util.massToRadius(c.foodMass);
|
|
|
+ var radius = util.massToRadius(1);
|
|
|
var distance = util.randomInRange(mCell.radius+25,mCell.radius+25+(c.mothercell.foodLimit/5));
|
|
|
var position = util.relativePosition({x:mCell.x,y:mCell.y},distance);
|
|
|
mothercellFood.push({
|
|
@@ -120,7 +121,7 @@ function mothercellAddFood(mCell,toAdd,limit=true) {
|
|
|
x: position.x,
|
|
|
y: position.y,
|
|
|
radius: radius,
|
|
|
- mass: c.foodMass,
|
|
|
+ mass: 1,
|
|
|
hue: Math.round(Math.random() * 360),
|
|
|
for: mCell.id
|
|
|
});
|
|
@@ -335,14 +336,14 @@ function moveMass(mass) {
|
|
|
}
|
|
|
|
|
|
function balanceMass() {
|
|
|
- var totalMass = food.length * c.foodMass +
|
|
|
+ var totalMass = food.length * (c.foodMass.from+c.foodMass.to)/2 +
|
|
|
users
|
|
|
.map(function(u) {return u.massTotal; })
|
|
|
.reduce(function(pu,cu) { return pu+cu;}, 0);
|
|
|
|
|
|
var massDiff = c.gameMass - totalMass;
|
|
|
var maxFoodDiff = c.maxFood - food.length;
|
|
|
- var foodDiff = parseInt(massDiff / c.foodMass) - maxFoodDiff;
|
|
|
+ var foodDiff = parseInt(massDiff / (c.foodMass.from+c.foodMass.to)/2) - maxFoodDiff;
|
|
|
var foodToAdd = Math.min(foodDiff, maxFoodDiff);
|
|
|
var foodToRemove = -Math.max(foodDiff, maxFoodDiff);
|
|
|
|
|
@@ -812,7 +813,7 @@ function tickPlayer(currentPlayer) {
|
|
|
sockets[collision.bUser.id].emit('RIP');
|
|
|
}
|
|
|
}
|
|
|
- mothercellAddFood(collision.aUser,Math.round(collision.bUser.mass/c.foodMass),false);
|
|
|
+ mothercellAddFood(collision.aUser,Math.round(collision.bUser.mass),false);
|
|
|
}
|
|
|
}
|
|
|
|