32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
// the base game's bworld:smelting and bworld:fuel recipes, as another mod adding to them sees them
|
|
import { assertEquals, assertRejects } from "@std/assert";
|
|
import { recipe_lookup } from "@/common/mod_loader.ts";
|
|
import { recipes_mod, test_game } from "./helpers.ts";
|
|
|
|
Deno.test("a later fuel recipe for an item changes how long it burns, and leaves the rest of the earlier one", async () => {
|
|
const dir = recipes_mod({ coal: { type: "bworld:fuel", item: ["bworld:coal", "bworld:oak_log"], burn_time: 50 } });
|
|
const { game } = await test_game(dir);
|
|
Deno.removeSync(dir, { recursive: true });
|
|
const recipes = recipe_lookup(() => game.recipes);
|
|
const burn_time = (id: string) => recipes.find<{ burn_time: number }>("bworld:fuel", id)?.burn_time;
|
|
assertEquals(burn_time("bworld:coal"), 50);
|
|
assertEquals(burn_time("bworld:oak_log"), 50);
|
|
assertEquals(burn_time("bworld:spruce_log"), 100);
|
|
});
|
|
|
|
Deno.test("two smelting recipes for one item stop the mod loading", async () => {
|
|
const dir = recipes_mod({
|
|
iron: {
|
|
type: "bworld:smelting",
|
|
input: "bworld:iron_ore",
|
|
output: { id: "bworld:stone", count: 1 },
|
|
cook_time: 10,
|
|
},
|
|
});
|
|
await assertRejects(() => test_game(dir), Error, "there's already one for bworld:iron_ore");
|
|
Deno.removeSync(dir, { recursive: true });
|
|
});
|