Vaguely import every tile

This commit is contained in:
2026-11-21 10:33:28 -03:00
parent 04c9511b6c
commit 65865033c1
40 changed files with 71 additions and 9 deletions
+24
View File
@@ -121,3 +121,27 @@ Deno.test("vent spots are in the plan where their rooms put them, turned with th
assert(spots.length > 0);
assertEquals(result.vent_spots, spots);
});
Deno.test("a room with entries is only attached to another by them", () => {
const types: TileType[] = [
{ id: "test:main", size: [9, 6, 9], doorways: cross, vent_spots: [], weight: 0 },
{ id: "test:hallway", size: [9, 6, 9], doorways: cross, entries: [cross[0]], vent_spots: [], weight: 1 },
];
for (const seed of ["a", "b", "c"]) {
const result = plan_interior(new Alea(seed), types, {
main: "test:main",
origin: { x: 0, y: 0, z: 0 },
rooms: 20,
});
const connected = new Set(result.doorways.filter((d) => d.connected).map(({ x, y, z }) => `${x},${y},${z}`));
for (const { tile, position, rotation } of result.tiles.slice(1)) {
// the entry, the north doorway, where it is once the hallway is turned
let [x, z] = [cross[0].x, cross[0].z];
for (let i = 0; i < rotation / 90; i++) [x, z] = [-z, x];
assert(
connected.has(`${position.x + x},${position.y + cross[0].y},${position.z + z}`),
`${tile} at ${seed}`,
);
}
}
});