32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
// the bundle is everything generation reads, so a worker sent it generates what the game does. see
|
|
// common/worldgen_bundle.ts and GENERATION.md
|
|
import { assert, assertEquals } from "@std/assert";
|
|
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
|
import { load_bundle } from "$/common/worldgen_bundle.ts";
|
|
import { test_game } from "./helpers.ts";
|
|
import { golden_chunks, namer, raw_hash, recorded, SEEDS } from "./golden.ts";
|
|
|
|
Deno.test("a bundle, cloned like a message to a worker and loaded into an empty registry, generates the golden chunks", async () => {
|
|
const fixture = recorded();
|
|
for (const seed of SEEDS) {
|
|
const { game } = await test_game("mods", undefined, seed);
|
|
const bundle = structuredClone(game.worldgen_bundle!);
|
|
const game_ids = { ...game.world.block_ids };
|
|
|
|
// nothing left from the game, like a fresh worker
|
|
EverythingRegistry.clear();
|
|
const loaded = await load_bundle(bundle);
|
|
assertEquals(loaded.block_ids, game_ids, "blocks are numbered like the game numbers them");
|
|
assert(loaded.setup.features.some((f) => f.id === "bworld:trees"), "bworld's worldgen script was loaded");
|
|
|
|
const name = namer(loaded.block_ids);
|
|
for (const [x, z] of golden_chunks()) {
|
|
assertEquals(
|
|
await raw_hash(loaded.generate(x, z), name),
|
|
fixture[seed][`${x},${z}`].raw,
|
|
`${seed} ${x},${z}`,
|
|
);
|
|
}
|
|
}
|
|
});
|