Add browser-only editor export and 2.5D runtime presentation

This commit is contained in:
emil28092005
2026-09-12 00:05:19 +03:00
parent a25ed40805
commit 1a0bf725fa
16 changed files with 883 additions and 53 deletions
+24
View File
@@ -0,0 +1,24 @@
import test from "node:test";
import assert from "node:assert/strict";
import { normalizeHud } from "../engine/presentation.ts";
test("HUD bounds script values and handles malformed meter entries", () => {
const h = normalizeHud({
objective: "x".repeat(300),
counters: [1, 2, 3, 4, 5],
meters: [
null,
{ id: "life", max: 5, value: 12, style: "hearts" },
{ max: 0, value: NaN },
{ max: 10, value: -3 },
],
});
assert.equal(h.objective!.length, 180);
assert.equal(h.counters!.length, 4);
assert.equal(h.meters![0].value, 0);
assert.equal(h.meters![1].value, 5);
assert.equal(h.meters![1].style, "hearts");
assert.equal(h.meters![2].max, 1);
assert.equal(h.meters![3].value, 0);
assert.deepEqual(normalizeHud(null), {});
assert.equal(normalizeHud({ overlay: null }).overlay, null);
});