Juices on the mechanical press !

This commit is contained in:
2026-10-31 00:03:03 -03:00
parent 3734f5707a
commit 23d02c5229
11 changed files with 381 additions and 62 deletions
+28
View File
@@ -7,6 +7,7 @@ import { assert, assertEquals } from "@std/assert";
import { ItemStack } from "$/common/inventory.ts";
import type { ItemStack as Stack } from "bworld/shared";
import {
apply_basin_recipe,
BASIN_SLOTS,
BASIN_TANK_CAPACITY,
BASIN_TANKS,
@@ -56,6 +57,33 @@ Deno.test("a basin keeps each fluid in a tank of its own, and drains the first",
assertEquals(drained.tanks.length, BASIN_TANKS - 1);
});
Deno.test("a basin recipe takes an item for each ingredient, and puts what it makes where recipes don't take it", () => {
const max = () => 64;
const basin = {
items: [{ id: "a:flint", count: 3 }, { id: "a:gravel", count: 1 }],
outputs: [{ id: "a:andesite", count: 1 }],
tanks: [],
};
const andesite = {
ingredients: [["a:flint"], ["a:flint"], ["a:gravel", "a:sand"]],
results: [{ id: "a:andesite", count: 1 }],
fluid_results: [{ fluid: juice("a:stone"), amount: 10 }],
};
const made = apply_basin_recipe(basin, andesite, max, same)!;
assertEquals(made.items, [{ id: "a:flint", count: 1 }]);
assertEquals(made.outputs, [{ id: "a:andesite", count: 2 }]);
assertEquals(made.tanks, [{ fluid: juice("a:stone"), amount: 10 }]);
// what it made isn't taken again, and the one flint left isn't enough
assertEquals(apply_basin_recipe(made, andesite, max, same), undefined);
assertEquals(
apply_basin_recipe({ ...basin, outputs: [] }, { ...andesite, ingredients: [["a:andesite"]] }, max, same),
undefined,
);
// nothing is made when what it makes doesn't all fit
const full = { ...basin, tanks: [{ fluid: juice("a:stone"), amount: BASIN_TANK_CAPACITY }] };
assertEquals(apply_basin_recipe(full, andesite, max, same), undefined);
});
// a basin at 0 100 0, and what's in it
async function basin() {
const t = await setup();