comparison game/js/map.js @ 23:2f555a54c332

layout fixes and balancing
author ark
date 2026-10-20 12:04 +0200
parents fe680946164b
children a464bd43b76c
comparison
equal deleted inserted replaced
22:ad1b478fc4dc 23:2f555a54c332
26 this.ys.push(p[i + 1]); 26 this.ys.push(p[i + 1]);
27 this.at.push(d); 27 this.at.push(d);
28 } 28 }
29 this.length = d; 29 this.length = d;
30 this.value = data.value; 30 this.value = data.value;
31 this.weight = data.weight;
32 this.sideways(maxOffset); 31 this.sideways(maxOffset);
33 } 32 }
34 33
35 // set up the sideways direction at each point (nx, ny) and how far an 34 // set up the sideways direction at each point (nx, ny) and how far an
36 // offset may go to the left and right there (left, right) 35 // offset may go to the left and right there (left, right)
205 return total ? c >= SIDE_SHARE * total : i === nearSide; 204 return total ? c >= SIDE_SHARE * total : i === nearSide;
206 }); 205 });
207 }; 206 };
208 207
209 // route weights for a monster of the given speed (balance.md, route 208 // route weights for a monster of the given speed (balance.md, route
210 // preference). fixed weights from routes.toml take precedence. 209 // preference)
211 GameMap.prototype.routeWeights = function (speed) { 210 GameMap.prototype.routeWeights = function (speed) {
212 var rp = cfg.route_preference; 211 var rp = cfg.route_preference;
213 var f = MM.util.clamp((speed - rp.reference_speed) / rp.reference_speed, -1, 1); 212 var f = MM.util.clamp((speed - rp.reference_speed) / rp.reference_speed, -1, 1);
214 return this.routes.map(function (r) { 213 return this.routes.map(function (r) {
215 if (r.weight !== null) return r.weight;
216 return Math.max(rp.min_weight, 1 + rp.bias * f * (2 * r.value - 1)); 214 return Math.max(rp.min_weight, 1 + rp.bias * f * (2 * r.value - 1));
217 }); 215 });
218 }; 216 };
219 217
220 // index of the shortest route, leaving out routes with a fixed weight 218 // index of the shortest route
221 // of 0 in routes.toml
222 GameMap.prototype.shortestRoute = function () { 219 GameMap.prototype.shortestRoute = function () {
223 var best = -1; 220 var best = -1;
224 this.routes.forEach(function (r, i) { 221 this.routes.forEach(function (r, i) {
225 if (r.weight === 0) return;
226 if (best < 0 || r.length < this.routes[best].length) best = i; 222 if (best < 0 || r.length < this.routes[best].length) best = i;
227 }, this); 223 }, this);
228 return best; 224 return best;
229 }; 225 };
230 226