aether-shards/test/generation/CrystalSpires.test.js

66 lines
1.8 KiB
JavaScript
Raw Normal View History

import { expect } from "@esm-bundle/chai";
import { VoxelGrid } from "../../src/grid/VoxelGrid.js";
import { CrystalSpiresGenerator } from "../../src/generation/CrystalSpiresGenerator.js";
describe("System: Procedural Generation (Crystal Spires)", () => {
let grid;
beforeEach(() => {
// Taller grid for verticality
grid = new VoxelGrid(20, 15, 20);
});
it("CoA 1: Should generate vertical columns (Spires)", () => {
const gen = new CrystalSpiresGenerator(grid, 12345);
gen.generate(1, 0); // 1 Spire, 0 Islands
// Check if the spire goes from bottom to top
// Finding a solid column
let solidColumnFound = false;
// Scan roughly center
for (let x = 5; x < 15; x++) {
for (let z = 5; z < 15; z++) {
if (grid.getCell(x, 0, z) !== 0 && grid.getCell(x, 14, z) !== 0) {
solidColumnFound = true;
break;
}
}
}
expect(solidColumnFound).to.be.true;
});
it("CoA 2: Should generate floating islands with void below", () => {
const gen = new CrystalSpiresGenerator(grid, 999);
gen.generate(0, 5); // 0 Spires, 5 Islands
let floatingIslandFound = false;
for (let x = 0; x < 20; x++) {
for (let z = 0; z < 20; z++) {
for (let y = 5; y < 10; y++) {
// Look for Solid block with Air directly below it
if (grid.getCell(x, y, z) !== 0 && grid.getCell(x, y - 1, z) === 0) {
floatingIslandFound = true;
}
}
}
}
expect(floatingIslandFound).to.be.true;
});
it("CoA 3: Should generate bridges (ID 20)", () => {
const gen = new CrystalSpiresGenerator(grid, 12345);
gen.generate(2, 5); // Spires and Islands
let bridgeCount = 0;
for (let i = 0; i < grid.cells.length; i++) {
if (grid.cells[i] === 20) bridgeCount++;
}
expect(bridgeCount).to.be.greaterThan(0);
});
});