Refine Archive World navigation and gate progression
All checks were successful
Build Org Website / build (push) Successful in 38s

This commit is contained in:
gitea-actions
2026-07-30 10:02:58 +01:00
parent c06af38d80
commit 2f125f32ae
10 changed files with 301 additions and 80 deletions

View File

@@ -11,6 +11,24 @@ test("movement normalization prevents faster diagonals", () => {
assert.equal(Math.round(Math.hypot(diagonal.x, diagonal.y)), 175);
});
test("movement acceleration is frame-rate aware, responsive, and speed capped", () => {
const movement = data.AREAS.town.movement;
const first = systems.approachVelocity(0, 0, 1, 1, movement, 16, false);
assert.ok(Math.hypot(first.x, first.y) > 0);
assert.ok(Math.hypot(first.x, first.y) < movement.speed);
let velocity = { x: 0, y: 0 };
for (let frame = 0; frame < 120; frame += 1) {
velocity = systems.approachVelocity(velocity.x, velocity.y, 1, 1, movement, 16, false);
}
assert.equal(Math.round(Math.hypot(velocity.x, velocity.y)), movement.speed);
for (let frame = 0; frame < 20; frame += 1) {
velocity = systems.approachVelocity(velocity.x, velocity.y, 0, 0, movement, 16, false);
}
assert.deepEqual(velocity, { x: 0, y: 0 });
});
test("landmark discoveries deduplicate and complete at eight", () => {
let current = state.fresh("Ada", "brass");
current = systems.discover(current, "gate");
@@ -83,3 +101,27 @@ test("invalid collision positions resolve to a named safe spawn", () => {
assert.equal(systems.isSafe(safe.area, safe.x, safe.y), true);
assert.ok(["gate", "square", "library", "study", "inn", "workshop", "playroom", "museum", "garden"].includes(safe.spawn));
});
test("all declared safe spawns and enemy homes are outside collision geometry", () => {
Object.entries(data.AREAS).forEach(([areaId, area]) => {
Object.entries(area.safeSpawns).forEach(([spawnId, spawn]) => {
assert.equal(systems.isSafe(areaId, spawn.x, spawn.y), true, `${areaId}:${spawnId}`);
});
area.enemies.forEach((entry) => {
const spawn = Array.isArray(entry)
? { type: entry[0], x: entry[1], y: entry[2] }
: entry;
assert.equal(systems.isSafe(areaId, spawn.x, spawn.y), true, `${areaId}:${spawn.type}`);
assert.equal(systems.isCombatSafe(areaId, spawn.x, spawn.y), false, `${areaId}:${spawn.type} is in a safe zone`);
});
});
});
test("town landmarks and NPC interaction points remain reachable", () => {
Object.values(data.LANDMARKS).forEach((landmark) => {
assert.equal(systems.isSafe("town", landmark.x, landmark.y), true, `landmark:${landmark.id}`);
});
data.AREAS.town.npcs.forEach(([npcId, x, y]) => {
assert.equal(systems.isSafe("town", x, y), true, `npc:${npcId}`);
});
});