Tags for smithing recipes

This commit is contained in:
2026-11-13 20:19:37 -03:00
parent 51b5d148bd
commit d48fa8cca5
7 changed files with 130 additions and 47 deletions
+3 -22
View File
@@ -4,29 +4,10 @@
// 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 { copy_dir, test_game } from "./helpers.ts";
// the base game, and a mod after it with these recipes
function kiln_mod(recipes: Record<string, unknown>) {
const dir = Deno.makeTempDirSync({ prefix: "bworld_smelting_" });
copy_dir("mods/bworld", `${dir}/bworld`);
const write = (path: string, json: unknown) => {
Deno.mkdirSync(`${dir}/kiln/${path.split("/").slice(0, -1).join("/")}`, { recursive: true });
Deno.writeTextFileSync(`${dir}/kiln/${path}`, JSON.stringify(json));
};
write("manifest.json", {
format_version: 1,
id: "kiln",
name: "Kiln",
version: "1.0.0",
dependencies: [{ id: "bworld", version: "*" }],
});
for (const [name, recipe] of Object.entries(recipes)) write(`recipes/${name}.json`, { format_version: 1, recipe });
return dir;
}
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 = kiln_mod({ coal: { type: "bworld:fuel", item: ["bworld:coal", "bworld:oak_log"], burn_time: 50 } });
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);
@@ -37,7 +18,7 @@ Deno.test("a later fuel recipe for an item changes how long it burns, and leaves
});
Deno.test("two smelting recipes for one item stop the mod loading", async () => {
const dir = kiln_mod({
const dir = recipes_mod({
iron: {
type: "bworld:smelting",
input: "bworld:iron_ore",