World shape for dimension
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, SEA_LEVEL } from "@/common/constants.ts";
|
||||
import { CHUNK_AREA, SEA_LEVEL } from "@/common/constants.ts";
|
||||
import { generate_raw_chunk } from "@/common/generation.ts";
|
||||
import { test_game } from "./helpers.ts";
|
||||
|
||||
@@ -22,11 +22,12 @@ Deno.test("the overworld generates the same way every time, with water only belo
|
||||
|
||||
for (let i = 0; i < CHUNK_AREA; i++) {
|
||||
assert(blocks[i] !== 0, "the bottom of the world is solid");
|
||||
assertEquals(blocks[(CHUNK_HEIGHT - 1) * CHUNK_AREA + i], 0, "nothing reaches the top of the world");
|
||||
const top = (game.world.shape.height - 1) * CHUNK_AREA + i;
|
||||
assertEquals(blocks[top], 0, "nothing reaches the top of the world");
|
||||
}
|
||||
blocks.forEach((block, i) => {
|
||||
if (block === water) {
|
||||
assert(Math.floor(i / CHUNK_AREA) < SEA_LEVEL, "water above sea level");
|
||||
assert(game.world.shape.min_y + Math.floor(i / CHUNK_AREA) < SEA_LEVEL, "water above sea level");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user