Vaguely import every tile
This commit is contained in:
@@ -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}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user