view update

This commit is contained in:
2026-11-17 14:17:50 +01:00
parent 3e565cf8c7
commit e0496fa089
45 changed files with 2024 additions and 149 deletions

View File

@@ -9,6 +9,13 @@
const RC = (root.RC = root.RC || (typeof require === 'function' ? require('./parts.js') : {}));
const part = (b, slot) => (b && b[slot] ? RC.PARTS[b[slot]] || null : null);
const clamp = (v, a, c) => (v < a ? a : v > c ? c : v);
// per-robot proportions: height / width / length factor (default 1). Bigger = heavier + tougher + slower.
RC.bodyOf = b => {
const d = (b && b.body) || {};
return { hx: clamp(+d.hx || 1, 0.7, 1.6), wx: clamp(+d.wx || 1, 0.8, 1.4), lx: clamp(+d.lx || 1, 0.8, 1.3) };
};
const sizeFactor = bo => bo.hx * bo.wx * bo.lx;
RC.HP_SCALE = 3; // catalogue hp x this = hit points in the arena
@@ -19,7 +26,7 @@
const p = part(build, slot);
if (!p) { if (RC.REQUIRED[slot]) errors.push('need_' + slot); continue; }
if (p.slot !== slot) { errors.push('bad_' + slot); continue; }
weight += p.weight;
weight += slot === 'chassis' ? Math.round(p.weight * (0.4 + 0.6 * sizeFactor(RC.bodyOf(build)))) : p.weight;
if (slot === 'battery') supply += p.power; else power += p.power || 0;
}
if (weight > RC.WEIGHT_LIMIT) errors.push('overweight');
@@ -34,9 +41,12 @@
const mass = Math.max(30, v.weight);
let value = 0;
for (const slot of RC.SLOTS) { const p = part(build, slot); if (p) value += p.cost; }
const len = ch ? ch.len : 1.3, wid = ch ? ch.wid : 1.0;
const bo = RC.bodyOf(build), size = sizeFactor(bo);
const len = (ch ? ch.len : 1.3) * bo.lx, wid = (ch ? ch.wid : 1.0) * bo.wx;
return {
hp: ((ch ? ch.hp : 80) + (ar ? ar.hp : 0)) * RC.HP_SCALE,
body: bo,
topHeavy: bo.hx / ((bo.wx + bo.lx) / 2), // tall + narrow = easier to tip over
hp: (Math.round((ch ? ch.hp : 80) * (0.6 + 0.4 * size)) + (ar ? ar.hp : 0)) * RC.HP_SCALE,
reduce: ar ? ar.reduce : 0,
mass,
accel: (mo ? mo.force : 500) / mass * (wh ? Math.min(1.2, wh.grip / 8) : 1),
@@ -44,8 +54,8 @@
turn: (wh ? wh.turn : 2.5) * (1.15 - mass / 650),
grip: wh ? wh.grip : 6,
push: wh ? wh.push : 1,
len, wid, h: ch ? ch.h : 0.42,
rad: Math.hypot(len, wid) / 2 * 0.9, // close to the body corners so robots do not clip through each other
len, wid, h: (ch ? ch.h : 0.42) * bo.hx,
rad: Math.hypot(len, wid) / 2 * 0.95, // body corners - bigger = robots keep more distance, less clipping
weapon: we, tower: to, gadget: gd, armour: ar,
invertible: !!(wh && wh.invertible),
lowProfile: !!(ch && ch.lowProfile),