Files
Robot-Clash/game/parts.js
2026-11-15 17:08:11 +01:00

98 lines
9.0 KiB
JavaScript

/* Robot Clash - parts catalogue (no DOM). Loaded as a classic script (window.RC.PARTS) and in Node
(require('./parts.js') returns RC).
Slots: chassis, motor, wheels, battery (required, exactly one each), armour, weapon, tower (optional).
Common fields: id, slot, name (brand name, not translated), cost, weight (kg), power (draw; battery: supply).
Texts for each part: lang.js key 'pd_<id>' (short description, en + de). */
(function (root) {
'use strict';
const RC = (root.RC = root.RC || {});
RC.WEIGHT_LIMIT = 100; // kg, single weight class in v1
RC.SLOTS = ['chassis', 'motor', 'wheels', 'battery', 'armour', 'weapon', 'tower', 'gadget'];
RC.REQUIRED = { chassis: true, motor: true, wheels: true, battery: true };
const P = [
// chassis: hp, body size (len along forward, wid, h), shape for the 3D model
{ id: 'crate', slot: 'chassis', name: 'Crate Mk1', cost: 150, weight: 22, hp: 100, len: 1.3, wid: 1.0, h: 0.42, shape: 'box' },
{ id: 'doorstop', slot: 'chassis', name: 'Doorstop', cost: 380, weight: 25, hp: 105, len: 1.45, wid: 1.05, h: 0.34, shape: 'wedge', lowProfile: true },
{ id: 'bulwark', slot: 'chassis', name: 'Bulwark', cost: 720, weight: 34, hp: 150, len: 1.5, wid: 1.2, h: 0.5, shape: 'box' },
{ id: 'scarab', slot: 'chassis', name: 'Scarab', cost: 1150, weight: 30, hp: 135, len: 1.4, wid: 1.15, h: 0.46, shape: 'dome', frontArmour: 0.15 },
{ id: 'cage', slot: 'chassis', name: 'Scrap Cage', cost: 260, weight: 17, hp: 85, len: 1.35, wid: 1.1, h: 0.46, shape: 'frame' },
{ id: 'hexpod', slot: 'chassis', name: 'Hexpod', cost: 520, weight: 24, hp: 115, len: 1.35, wid: 1.15, h: 0.44, shape: 'hex' },
{ id: 'boiler', slot: 'chassis', name: 'Boiler', cost: 640, weight: 29, hp: 130, len: 1.3, wid: 1.1, h: 0.52, shape: 'barrel' },
{ id: 'fang', slot: 'chassis', name: 'Fang', cost: 860, weight: 26, hp: 120, len: 1.55, wid: 1.0, h: 0.36, shape: 'arrow', lowProfile: true, frontArmour: 0.12 },
{ id: 'plough', slot: 'chassis', name: 'Snowplough', cost: 980, weight: 36, hp: 150, len: 1.45, wid: 1.2, h: 0.42, shape: 'plow', frontArmour: 0.22 },
{ id: 'discus', slot: 'chassis', name: 'Discus', cost: 1350, weight: 32, hp: 155, len: 1.5, wid: 1.35, h: 0.3, shape: 'saucer', lowProfile: true },
// motor: force (N), top speed (m/s)
{ id: 'sparky', slot: 'motor', name: 'Sparky 2kW', cost: 100, weight: 8, power: 3, force: 650, speed: 4.0 },
{ id: 'hornet', slot: 'motor', name: 'Hornet 3kW', cost: 420, weight: 10, power: 5, force: 850, speed: 5.0 },
{ id: 'bulldog', slot: 'motor', name: 'Bulldog Torque', cost: 680, weight: 14, power: 6, force: 1250, speed: 4.3 },
{ id: 'comet', slot: 'motor', name: 'Comet 5kW', cost: 1250, weight: 12, power: 8, force: 1150, speed: 6.2 },
// wheels: speed factor, lateral grip, turn rate (rad/s), push factor; invertible = drives upside down
{ id: 'rubber', slot: 'wheels', name: 'Rubber 4x', cost: 60, weight: 4, speedMul: 1.0, grip: 7, turn: 2.8, push: 1.0, kind: 'small' },
{ id: 'omni', slot: 'wheels', name: 'Omni Casters', cost: 360, weight: 6, speedMul: 1.05, grip: 9, turn: 3.4, push: 0.95, kind: 'omni' },
{ id: 'bigtyre', slot: 'wheels', name: 'Big Tyres', cost: 280, weight: 7, speedMul: 1.1, grip: 7.5, turn: 2.5, push: 1.05, kind: 'big', invertible: true },
{ id: 'studs', slot: 'wheels', name: 'Studded Tyres', cost: 460, weight: 9, speedMul: 1.0, grip: 10, turn: 2.6, push: 1.2, kind: 'stud', invertible: true },
{ id: 'drumwh', slot: 'wheels', name: 'Roller Drum', cost: 600, weight: 10, speedMul: 1.15, grip: 8, turn: 2.0, push: 1.3, kind: 'drum' },
{ id: 'tracks', slot: 'wheels', name: 'Crawler Tracks', cost: 540, weight: 11, speedMul: 0.86, grip: 12, turn: 2.2, push: 1.45, kind: 'tracks' },
{ id: 'hover', slot: 'wheels', name: 'Hover Skirt', cost: 900, weight: 8, power: 4, speedMul: 1.25, grip: 5, turn: 3.0, push: 0.8, kind: 'hover', invertible: true },
// battery: power = supply
{ id: 'lead', slot: 'battery', name: 'Lead 12V', cost: 80, weight: 10, power: 9 },
{ id: 'nicd', slot: 'battery', name: 'NiCd Pack', cost: 320, weight: 7, power: 13 },
{ id: 'lipo', slot: 'battery', name: 'LiPo Stack', cost: 760, weight: 5, power: 19 },
// armour: reduce = share of damage absorbed, hp bonus
{ id: 'mesh', slot: 'armour', name: 'Wire Mesh', cost: 120, weight: 5, reduce: 0.08, hp: 4, tint: 0x9aa3ad, style: 'mesh' },
{ id: 'steel', slot: 'armour', name: 'Steel Plates', cost: 220, weight: 12, reduce: 0.15, hp: 10, tint: 0x8a9099, style: 'plates' },
{ id: 'buffer', slot: 'armour', name: 'Rubber Buffers', cost: 300, weight: 8, reduce: 0.18, hp: 8, tint: 0x33343a, style: 'bumper' },
{ id: 'spiked', slot: 'armour', name: 'Spiked Plates', cost: 520, weight: 14, reduce: 0.22, hp: 12, tint: 0x7d868f, style: 'spike' },
{ id: 'titan', slot: 'armour', name: 'Titanium Skin', cost: 680, weight: 9, reduce: 0.25, hp: 15, tint: 0xa9b8c9, style: 'plates' },
{ id: 'ceramic', slot: 'armour', name: 'Ceramic Tiles', cost: 900, weight: 11, reduce: 0.32, hp: 14, tint: 0xd8d2c4, style: 'tiles' },
{ id: 'hardox', slot: 'armour', name: 'Hardox Shell', cost: 1150, weight: 18, reduce: 0.38, hp: 25, tint: 0xc9a845, style: 'plates' },
// weapons (Space): type decides the behaviour in combat.js
{ id: 'wedge', slot: 'weapon', name: 'Steel Wedge', cost: 80, weight: 6, power: 0, type: 'wedge', reach: 0.35, ram: 1.7, cd: 4 },
{ id: 'flipper', slot: 'weapon', name: 'Pneumatic Flipper', cost: 480, weight: 14, power: 6, type: 'flipper', reach: 0.55, dmg: 8, launch: 7.5, cd: 2.2 },
{ id: 'hammer', slot: 'weapon', name: 'Axe Hammer', cost: 560, weight: 12, power: 5, type: 'hammer', reach: 0.8, dmg: 22, cd: 1.5 },
{ id: 'saw', slot: 'weapon', name: 'Circular Saw', cost: 420, weight: 9, power: 5, type: 'saw', reach: 0.4, dps: 24 },
{ id: 'crusher', slot: 'weapon', name: 'Hydraulic Jaws', cost: 780, weight: 15, power: 7, type: 'crusher', reach: 0.5, dps: 20, hold: 2.2, cd: 3.5 },
{ id: 'spinner', slot: 'weapon', name: 'Bar Spinner', cost: 950, weight: 18, power: 9, type: 'spinner', reach: 0.6, dmg: 34, spinup: 1.4 },
{ id: 'lance', slot: 'weapon', name: 'Ram Lance', cost: 300, weight: 8, power: 0, type: 'wedge', reach: 0.5, ram: 2.3, cd: 4 },
{ id: 'drill', slot: 'weapon', name: 'Auger Drill', cost: 560, weight: 11, power: 6, type: 'saw', reach: 0.45, dps: 28 },
{ id: 'mace', slot: 'weapon', name: 'Spiked Mace', cost: 640, weight: 13, power: 5, type: 'hammer', reach: 0.9, dmg: 26, cd: 1.7 },
{ id: 'launcher', slot: 'weapon', name: 'Scoop Launcher', cost: 700, weight: 15, power: 7, type: 'flipper', reach: 0.6, dmg: 6, launch: 9.5, cd: 2.6 },
{ id: 'drum', slot: 'weapon', name: 'Drum Spinner', cost: 820, weight: 16, power: 8, type: 'spinner', reach: 0.5, dmg: 26, spinup: 1.0 },
{ id: 'lifter', slot: 'weapon', name: 'Scoop Lifter', cost: 340, weight: 10, power: 4, type: 'lifter', reach: 0.5, dmg: 4, launch: 3.2, cd: 1.2 },
{ id: 'vdisc', slot: 'weapon', name: 'Vertical Disc', cost: 1100, weight: 17, power: 9, type: 'vspinner', reach: 0.5, dmg: 30, spinup: 1.5 },
// towers (Shift / E): auto-aiming turret on top
{ id: 'flamer', slot: 'tower', name: 'Flame Nozzle', cost: 360, weight: 6, power: 3, type: 'flamer', range: 2.8, dps: 10, cone: 0.4 },
{ id: 'minigun', slot: 'tower', name: 'Rivet Minigun', cost: 520, weight: 7, power: 4, type: 'minigun', range: 9, dps: 8 },
{ id: 'rockets', slot: 'tower', name: 'Seeker Pod', cost: 840, weight: 10, power: 5, type: 'rockets', range: 14, dmg: 17, cd: 2.4 },
{ id: 'zapper', slot: 'tower', name: 'Arc Zapper', cost: 600, weight: 8, power: 6, type: 'zapper', range: 3.4, dps: 15 },
{ id: 'mortar', slot: 'tower', name: 'Mortar Tube', cost: 760, weight: 11, power: 5, type: 'mortar', range: 11, dmg: 26, cd: 3.0, splash: 1.7 },
{ id: 'swarm', slot: 'tower', name: 'Swarm Pod', cost: 1150, weight: 12, power: 6, type: 'swarm', range: 22, dmg: 9, cd: 3.6, shots: 3 },
// gadgets (G): one-shot abilities on a cooldown; optional slot
{ id: 'righter', slot: 'gadget', name: 'Self-Righter', cost: 180, weight: 5, power: 2, type: 'righter', cd: 4 },
{ id: 'turbo', slot: 'gadget', name: 'Nitro Boost', cost: 300, weight: 6, power: 3, type: 'turbo', cd: 7, dur: 1.2 },
{ id: 'shield', slot: 'gadget', name: 'Deflector Field', cost: 420, weight: 7, power: 4, type: 'shield', cd: 9, dur: 2.5, reduce: 0.6 },
{ id: 'repair', slot: 'gadget', name: 'Repair Kit', cost: 500, weight: 8, power: 3, type: 'repair', cd: 8, charges: 2, heal: 0.26 },
{ id: 'emp', slot: 'gadget', name: 'EMP Burst', cost: 640, weight: 7, power: 5, type: 'emp', cd: 8, range: 3.2, stun: 1.5 },
];
RC.PARTS = {};
for (const p of P) RC.PARTS[p.id] = p;
RC.PART_LIST = P;
RC.partsFor = slot => P.filter(p => p.slot === slot);
// starter robot: owned on a new save
RC.STARTER = { chassis: 'crate', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'wedge', tower: null };
if (typeof module !== 'undefined' && module.exports) module.exports = RC;
})(typeof window !== 'undefined' ? window : globalThis);