Juicer press wow

This commit is contained in:
2026-10-25 19:14:29 -03:00
parent a28e0b9abb
commit c955d8d143
8 changed files with 235 additions and 49 deletions
+31 -4
View File
@@ -96,6 +96,7 @@ Deno.test("the juicer takes juiceable items, juices one every 4 presses, and fil
// what's in it and its juice, which clients see
const shown = () => t.game.world.get_tile(1, 100, 0)?.client_data?.stack;
const tank = () => t.game.world.get_tile(1, 100, 0)?.client_data?.tank;
const presses = () => t.game.world.get_tile(1, 100, 0)?.client_data?.presses;
const juice = { id: "bworld:juice", data: { item: CLOUDBERRY } };
hold(CLOUDBERRY);
use();
@@ -107,14 +108,14 @@ Deno.test("the juicer takes juiceable items, juices one every 4 presses, and fil
// 2 cloudberries and 3 presses toward the next are 200 mB, not a bottle's 250
press(11);
assertEquals(tank(), { fluid: juice, amount: 200 });
assertEquals([tank(), presses()], [{ fluid: juice, amount: 200 }, 3]);
hold("bworld:glass_bottle");
use();
assertEquals(bottles(), [{ id: "bworld:glass_bottle", count: 2 }]);
// the 3rd makes 300 mB, a bottle and 50 mB left, which isn't another
press(1);
assertEquals(shown(), { id: CLOUDBERRY, count: 1 });
assertEquals([shown(), presses()], [{ id: CLOUDBERRY, count: 1 }, undefined]);
hold("bworld:glass_bottle");
use();
use();
@@ -163,11 +164,15 @@ async function drawn_juicer() {
return { visuals, set, done };
}
Deno.test("the juicer draws what's in it, more of it the more there is, and nothing when it's empty", async () => {
Deno.test("the juicer draws its press, what's in it, more of it the more there is, and nothing when it's empty", async () => {
const { visuals, set, done } = await drawn_juicer();
// the press, whatever's in it
const press = [...visuals.groups()].filter((group) => group.instances.length > 0);
assertEquals(press.map((group) => group.instances.length), [1]);
// one item, however many of it are drawn
const drawn = () =>
[...visuals.groups()].filter((group) => group.instances.length > 0).map((group) => group.instances.length);
[...visuals.groups()].filter((group) => !press.includes(group) && group.instances.length > 0)
.map((group) => group.instances.length);
set("stack", { id: CLOUDBERRY, count: 1 });
const one = drawn();
@@ -203,3 +208,25 @@ Deno.test("the juicer's juice fills its 12 by 12 floor, a pixel deep while there
assertEquals(boxes(), []);
done();
});
Deno.test("the juicer's press goes down a share of the way each press, easing there, and back up once there's juice", async () => {
const { visuals, set, done } = await drawn_juicer();
const [press] = [...visuals.groups()].filter((group) => group.instances.length > 0);
// how far below its block it is
const down = () => 100 - press.instances[0].placement[13];
const frame = (time: number) => visuals.frame([{ x: 0, z: 0 }], time);
frame(0);
assertEquals(down(), 0);
// half way to the 4th press, which would take it 6 pixels down to the floor
set("presses", 2);
frame(1);
assert(down() > 0 && down() < 3 / 16, `${down()}`);
frame(5);
assertEquals(down(), 3 / 16);
// the juice is made, so it's back up
set("presses", undefined);
frame(9);
assertEquals(down(), 0);
done();
});