2026-11-13 00:41:54 +01:00
|
|
|
/* Robot Clash - workshop rules and robot stats from parts (no DOM). Needs parts.js.
|
|
|
|
|
|
|
|
|
|
RC.validate(build) -> { ok, errors: ['need_chassis' | 'overweight' | 'no_power' ...], weight, power, supply }
|
|
|
|
|
RC.stats(build) -> combat stats { hp, reduce, mass, accel, top, turn, grip, push, len, wid, h, rad,
|
|
|
|
|
weapon, tower, invertible, lowProfile, frontArmour, value }
|
|
|
|
|
build = { chassis: id, motor: id, wheels: id, battery: id, armour: id|null, weapon: id|null, tower: id|null } */
|
|
|
|
|
(function (root) {
|
|
|
|
|
'use strict';
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
RC.HP_SCALE = 3; // catalogue hp x this = hit points in the arena
|
|
|
|
|
|
|
|
|
|
RC.validate = build => {
|
|
|
|
|
const errors = [];
|
|
|
|
|
let weight = 0, power = 0, supply = 0;
|
|
|
|
|
for (const slot of RC.SLOTS) {
|
|
|
|
|
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;
|
|
|
|
|
if (slot === 'battery') supply += p.power; else power += p.power || 0;
|
|
|
|
|
}
|
|
|
|
|
if (weight > RC.WEIGHT_LIMIT) errors.push('overweight');
|
|
|
|
|
if (supply && power > supply) errors.push('no_power');
|
|
|
|
|
return { ok: errors.length === 0, errors, weight, power, supply };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RC.stats = build => {
|
|
|
|
|
const ch = part(build, 'chassis'), mo = part(build, 'motor'), wh = part(build, 'wheels');
|
2026-11-15 17:08:11 +01:00
|
|
|
const ar = part(build, 'armour'), we = part(build, 'weapon'), to = part(build, 'tower'), gd = part(build, 'gadget');
|
2026-11-13 00:41:54 +01:00
|
|
|
const v = RC.validate(build);
|
|
|
|
|
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;
|
|
|
|
|
return {
|
|
|
|
|
hp: ((ch ? ch.hp : 80) + (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),
|
|
|
|
|
top: (mo ? mo.speed : 3.5) * (wh ? wh.speedMul : 1) * (1.12 - mass / 900),
|
|
|
|
|
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,
|
Online-Lobby, Arenen, Lackiererei, ComfyGen-Grafik, Verschleierung
Grosse Erweiterung ueber die erste spielbare Version hinaus:
- Online (Firebase ueber REST, kein SDK): Konto per E-Mail, globale Lobby
mit Laender-Raeumen, Herausfordern, Live-PvP (Host rechnet, Gast
interpoliert, KI-Uebernahme bei Lag). Gast kann anonym beitreten.
net.js / lobby.js / netfight.js, Regeln in docs/firebase.
- 3 Arenen in verschiedenen Groessen (RC.ARENAS, half 8/12/16), Kamera +
Licht + Boden skalieren; Liga skaliert die Arena mit, Setting + online
aus Seed. Harte Rams/Wandtreffer schleudern Roboter auf den Rucken.
- Intro (3D-Kamerafahrt), Titel, Einstellungen (Kamera, Schwierigkeit,
Steuerung, Grafik, Arena), Lackiererei (painter.js, selbst bemalen).
- Shop mit ComfyGen-Sprites (aus den 3D-Teilen erzeugt), Liga-Gegner sehen
aus wie ihre Portraits (looks.js), kraeftigere Waffen-Modelle.
- Oekonomie: Startgeld 800, Schadensbonus, Schaukaempfe, Online-Preisgeld.
- Verschleierung: build.ps1 -Obfuscate (terser), tablet-taugliche Touch-UI.
- Tests: tests/sim.test.js, balance.js, online.test.js. Dev-Tools in tools/.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-13 15:45:35 +01:00
|
|
|
rad: Math.hypot(len, wid) / 2 * 0.9, // close to the body corners so robots do not clip through each other
|
2026-11-15 17:08:11 +01:00
|
|
|
weapon: we, tower: to, gadget: gd, armour: ar,
|
2026-11-13 00:41:54 +01:00
|
|
|
invertible: !!(wh && wh.invertible),
|
|
|
|
|
lowProfile: !!(ch && ch.lowProfile),
|
|
|
|
|
frontArmour: ch && ch.frontArmour ? ch.frontArmour : 0,
|
|
|
|
|
value,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined' && module.exports) module.exports = RC;
|
|
|
|
|
})(typeof window !== 'undefined' ? window : globalThis);
|