Fermenting recipes
This commit is contained in:
@@ -14,6 +14,7 @@ import { AssetManager } from "$/client/assets.ts";
|
||||
import { fluid_rules, set_fluid_rules } from "$/client/fluid_rules.ts";
|
||||
import { setup as setup_client } from "$/mods/bworld/scripts/client.ts";
|
||||
import { JUICE_VALUE, type JuiceableParams } from "$/mods/bworld/scripts/shared.ts";
|
||||
import type { FermentableRecipe } from "$/mods/bworld/scripts/fermenting.ts";
|
||||
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
|
||||
|
||||
const CLOUDBERRY = "testberries:cloudberry";
|
||||
@@ -221,6 +222,47 @@ Deno.test("a broken juicing recipe stops the server from starting", async () =>
|
||||
await assertRejects(() => setup({ "broken.json": broken }), Error, "bworld:juicing recipe");
|
||||
});
|
||||
|
||||
Deno.test("every juice ferments into wine from the same fruit, named after it in its color", async () => {
|
||||
const { game, fluids } = await setup();
|
||||
const fermentable = game.recipes.by_type.get("bworld:fermentable") as unknown as FermentableRecipe[];
|
||||
const juiceable = EverythingRegistry.entries<ItemRegistry>("items")
|
||||
.filter(([, item]) => item.components?.["bworld:juiceable"]);
|
||||
assert(juiceable.some(([id]) => id === CLOUDBERRY));
|
||||
for (const [id, item] of juiceable) {
|
||||
const recipes = fermentable.filter((recipe) =>
|
||||
fluids.same(recipe.input.fluid, { id: "bworld:juice", data: { item: id } })
|
||||
);
|
||||
assertEquals(recipes.length, 1, id);
|
||||
const [recipe] = recipes;
|
||||
assertEquals(recipe.output.fluid, { id: "bworld:wine", data: { item: id } });
|
||||
assert(
|
||||
recipe.input.amount > 0 && recipe.output.amount > 0 && Number.isInteger(recipe.ticks) && recipe.ticks > 0,
|
||||
);
|
||||
assertEquals(fluids.name(recipe.output.fluid), `${display_name(id)} Wine`);
|
||||
assertEquals(
|
||||
fluids.color(recipe.output.fluid),
|
||||
(item.components!["bworld:juiceable"] as { color: string }).color,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test("a broken bworld:fermentable recipe stops the server from starting", async () => {
|
||||
const juice = { fluid: { id: "bworld:juice" }, amount: 100 };
|
||||
for (
|
||||
const broken of [
|
||||
{ input: juice, output: { fluid: { id: "nope:nothing" }, amount: 100 }, ticks: 1 },
|
||||
{ input: juice, output: juice, ticks: 0 },
|
||||
{ output: juice, ticks: 1 },
|
||||
]
|
||||
) {
|
||||
await assertRejects(
|
||||
() => setup({ "broken.json": { type: "bworld:fermentable", ...broken } }),
|
||||
Error,
|
||||
"bworld:fermentable recipe",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// a juicer at 1 100 1 drawn by bworld's client script, and a way to set a field of its client data. its fluids have the
|
||||
// server's rules, the same as a client's
|
||||
async function drawn_juicer() {
|
||||
|
||||
Reference in New Issue
Block a user