Skip to content
Make the player visible with a procedural 3D humanoid132be7c
JavaScript32 lines1.4 KB
import test from "node:test";import assert from "node:assert/strict";import fs from "node:fs";import path from "node:path"; const pub = path.resolve("public"); test("main.mjs only imports modules that are served from public/", () => {  const src = fs.readFileSync(path.join(pub, "main.mjs"), "utf8");  for (const m of src.matchAll(/from\s+"([^"]+)"/g)) {    assert.ok(!m[1].startsWith("../"), `import escapes assets dir: ${m[1]}`);    assert.ok(fs.existsSync(path.join(pub, m[1])), `missing asset: ${m[1]}`);  }}); test("bot mode runs end to end without the Worker", async () => {  const { createMatch, step, DT } = await import("../public/game/engine.mjs");  const { LEVELS } = await import("../public/game/levels.mjs");  const { createBot } = await import("../public/game/bot.mjs");  const { createInputTracker } = await import("../public/game/input.mjs");  const tracker = createInputTracker();  const bot = createBot({ difficulty: LEVELS[0].botDifficulty, seed: 7 });  let state = createMatch(LEVELS[0]);  const x0 = state.fighters[0].x;  tracker.keyDown("KeyD");  for (let i = 0; i < 30; i++) state = step(state, [tracker.snapshot(), bot.update(state)], DT);  assert.ok(state.fighters[0].x > x0, "player moved right");  tracker.keyUp("KeyD"); tracker.keyDown("KeyJ");  state = step(state, [tracker.snapshot(), bot.update(state)], DT);  assert.equal(state.fighters[0].stance, "punch");});