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>
This commit is contained in:
2026-11-13 15:45:35 +01:00
parent 819ee0a5c3
commit 7a69651b6d
60 changed files with 1895 additions and 207 deletions

View File

@@ -12,17 +12,36 @@
'use strict';
const RC = (root.RC = root.RC || {});
const ARENA = (RC.ARENA = {
half: 8, // floor from -8..8
duration: 120, // seconds
pitOpensAt: 60, // seconds left when the pit opens
pit: { x: 0, z: 4.6, hw: 1.35, hd: 1.35 },
saws: [{ x: -3.2, z: -3.4, r: 0.95, period: 6, on: 2.2, phase: 0 }, { x: 3.2, z: -3.4, r: 0.95, period: 6, on: 2.2, phase: 3 }],
flames: [{ x: -2.7, z: 3.3, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase: 1 }, { x: 2.7, z: 3.3, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase: 4.5 }],
press: { x: 6.25, z: -6.25, hw: 1.6, hd: 1.6 }, // guardian 1: forge press (corner)
crane: { x: -6.25, z: 6.25, hw: 1.6, hd: 1.6 }, // guardian 2: magnet crane (corner)
starts: [{ x: -5, z: 1.5, a: 0 }, { x: 5, z: 1.5, a: Math.PI }],
});
// Arena definitions. `half` = floor from -half..half. Hazards scale with the size. The active arena is
// RC.ARENA; a fight snapshots it into s.arena so several arenas can exist. render3d.js reads s.arena.
function arena(o) {
const h = o.half, g = h - 1.75; // guardian corners
return {
id: o.id, name: o.name, theme: o.theme || 'steel', half: h,
duration: 120, pitOpensAt: 60,
pit: { x: 0, z: o.pitZ != null ? o.pitZ : h * 0.52, hw: o.pitW || 1.35, hd: o.pitW || 1.35 },
saws: o.saws, flames: o.flames,
press: { x: g, z: -g, hw: 1.6, hd: 1.6 }, // guardian 1: forge press (corner)
crane: { x: -g, z: g, hw: 1.6, hd: 1.6 }, // guardian 2: magnet crane (corner)
starts: [{ x: -h * 0.6, z: h * 0.2, a: 0 }, { x: h * 0.6, z: h * 0.2, a: Math.PI }],
};
}
const saw = (x, z, phase) => ({ x, z, r: 0.95, period: 6, on: 2.2, phase });
const flame = (x, z, phase) => ({ x, z, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase });
RC.ARENAS = [
arena({ id: 'workshop', name: 'Workshop Pit', theme: 'steel', half: 8,
saws: [saw(-3.2, -3.4, 0), saw(3.2, -3.4, 3)],
flames: [flame(-2.7, 3.3, 1), flame(2.7, 3.3, 4.5)] }),
arena({ id: 'foundry', name: 'The Foundry', theme: 'lava', half: 12, pitW: 1.7,
saws: [saw(-5, -4.5, 0), saw(5, -4.5, 3), saw(0, 4.5, 1.5)],
flames: [flame(-4.5, 1, 0), flame(4.5, 1, 3.5), flame(0, -7.5, 2), flame(-7, 6, 5)] }),
arena({ id: 'arena64', name: 'Mega Dome', theme: 'blue', half: 16, pitW: 2.1,
saws: [saw(-6.5, -6, 0), saw(6.5, -6, 3), saw(-6.5, 6, 1.5), saw(6.5, 6, 4.5), saw(0, 0, 2)],
flames: [flame(-8, 2, 0), flame(8, 2, 2), flame(0, 9, 4), flame(0, -9, 1), flame(-10, -4, 3), flame(10, -4, 5)] }),
];
let ARENA = RC.ARENAS[0];
RC.ARENA = ARENA;
RC.setArena = id => { ARENA = RC.ARENAS.find(a => a.id === id) || RC.ARENAS[0]; RC.ARENA = ARENA; return ARENA; };
const G = 22; // gravity
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
@@ -35,8 +54,8 @@
const hazardOn = (h, t) => ((t + h.phase) % h.period) < h.on;
RC.hazardOn = hazardOn;
function makeRobot(st, i, name) {
const p = ARENA.starts[i];
function makeRobot(st, i, name, A) {
const p = A.starts[i];
return {
i, name, st, x: p.x, z: p.z, a: p.a, vx: 0, vz: 0, av: 0, y: 0, vy: 0,
hp: st.hp, maxHp: st.hp, dead: false, out: null, fall: 0,
@@ -47,12 +66,13 @@
}
function create(opt) {
const A = opt.arena ? (RC.ARENAS.find(a => a.id === opt.arena) || RC.ARENA) : RC.ARENA;
const s = {
t: 0, left: ARENA.duration, pitOpen: 0, rand: rng(opt.seed || 1),
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1))),
arena: A, t: 0, left: A.duration, pitOpen: 0, rand: rng(opt.seed || 1),
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1), A)),
rockets: [], events: [], result: null, endIn: 0,
press: { st: 'idle', t: 0, y: 1 }, // idle | warn | slam | up ; y 1 = top, 0 = floor
crane: { st: 'idle', t: 0, who: -1, tx: 0, tz: 0, x: ARENA.crane.x, z: ARENA.crane.z },
crane: { st: 'idle', t: 0, who: -1, tx: 0, tz: 0, x: A.crane.x, z: A.crane.z },
pitAlarm: false,
};
return s;
@@ -107,11 +127,11 @@
function step(s, dt, inputs) {
if (s.endIn > 0) { s.endIn -= dt; }
s.t += dt;
if (!s.result) s.left = Math.max(0, ARENA.duration - s.t);
if (!s.result) s.left = Math.max(0, s.arena.duration - s.t);
const R = s.robots;
// pit: opens at half time
if (s.left <= ARENA.pitOpensAt) {
if (s.left <= s.arena.pitOpensAt) {
if (!s.pitAlarm) { s.pitAlarm = true; s.events.push({ type: 'pit_open' }); }
s.pitOpen = Math.min(1, s.pitOpen + dt * 0.8);
}
@@ -176,7 +196,7 @@
}
// spike walls
const lim = ARENA.half - st.rad * 0.9;
const lim = s.arena.half - st.rad * 0.9;
for (const ax of ['x', 'z']) {
const vk = ax === 'x' ? 'vx' : 'vz';
if (Math.abs(r[ax]) > lim) {
@@ -186,6 +206,8 @@
if (vn > 1.8 && !r.out) {
s.events.push({ type: 'wall', who: r.i, x: r.x, z: r.z, speed: vn });
damage(s, r, (vn - 1.8) * 4.5, null, { kind: 'spikes' });
// slammed into the spikes hard -> bounces up and can land on its back
if (vn > 3.5 && r.y < 0.05 && !r.st.invertible && !r.st.lowProfile && s.rand() < 0.3) { r.vy = Math.max(r.vy, 2); r.flipped = 2.2; r.av += (s.rand() - 0.5) * 6; }
}
r[vk] = -r[vk] * 0.45;
}
@@ -222,7 +244,15 @@
const w = me.st.weapon;
const ram = w && w.type === 'wedge' ? w.ram : 1;
damage(s, e, (impact - 1) * 2.2 * ram, me, { kind: 'ram' });
if (w && w.type === 'wedge' && e.y < 0.05 && !e.st.lowProfile) { e.vy = 2.6; e.stun = Math.max(e.stun, 0.25); }
// a wedge scoops lighter robots up; any hard enough ram can send one tumbling onto its roof
if (w && w.type === 'wedge' && e.y < 0.05 && !e.st.lowProfile) {
const light = Math.sqrt(me.st.mass / e.st.mass);
e.vy = Math.max(e.vy, 2.3 * light); e.stun = Math.max(e.stun, 0.25);
if (!e.st.invertible && !e.st.lowProfile && s.rand() < 0.3 * light && impact > 3) { e.flipped = 2.2; e.av += (s.rand() - 0.5) * 6; }
} else if (impact > 4.5 && e.y < 0.05 && !e.st.lowProfile && !e.st.invertible) {
const light = Math.sqrt(me.st.mass / e.st.mass);
if (s.rand() < 0.22 * light) { e.vy = Math.max(e.vy, 1.8 * light); e.flipped = 2.2; e.av += (s.rand() - 0.5) * 5; s.events.push({ type: 'flip', who: e.i, x: e.x, z: e.z }); }
}
}
}
}
@@ -262,7 +292,7 @@
e.vx += fx * 3 * light; e.vz += fz * 3 * light;
e.av += (s.rand() - 0.5) * 6;
damage(s, e, w.dmg, r, { kind: 'flip' });
if (!e.st.invertible && s.rand() < (e.st.lowProfile ? 0.3 : 0.55)) e.flipped = 3.5;
if (!e.st.invertible && s.rand() < (e.st.lowProfile ? 0.25 : 0.45)) e.flipped = 2.2;
}
}
break;
@@ -337,7 +367,7 @@
k.x += Math.cos(k.a) * k.sp * dt; k.z += Math.sin(k.a) * k.sp * dt;
k.y += ((tgt.y + 0.35) - k.y) * Math.min(1, dt * 3);
const hit = !tgt.out && Math.hypot(tgt.x - k.x, tgt.z - k.z) < tgt.st.rad + 0.1;
const wall = Math.abs(k.x) > ARENA.half || Math.abs(k.z) > ARENA.half;
const wall = Math.abs(k.x) > s.arena.half || Math.abs(k.z) > s.arena.half;
if (hit || wall || k.t <= 0) {
s.events.push({ type: 'boom', x: k.x, z: k.z, y: k.y });
if (hit) {
@@ -350,7 +380,7 @@
}
function hazards(s, dt) {
const A = ARENA, R = s.robots;
const A = s.arena, R = s.robots;
for (const r of R) {
if (r.out) continue;
const ground = r.y < 0.15 && r.lifted <= 0;
@@ -416,7 +446,7 @@
c.st = 'idle'; c.t = 2.5; r.lifted = 0; r.vy = 0; r.craneT = 0;
s.events.push({ type: 'drop', who: r.i, x: r.x, z: r.z });
damage(s, r, 8, null, { kind: 'drop' });
if (!r.st.invertible && s.rand() < 0.5) r.flipped = 3.5;
if (!r.st.invertible && s.rand() < 0.4) r.flipped = 2.2;
c.who = -1;
}
}