Add tiers for watering cans

This commit is contained in:
2026-09-30 00:11:04 -03:00
parent d8d1ee4698
commit 69900f7007
22 changed files with 219 additions and 37 deletions
+4 -4
View File
@@ -159,18 +159,18 @@ Deno.test("the last bone meal is used up", async () => {
});
Deno.test("a new watering can starts empty, and players are told so in its lore", async () => {
const t = await setup([["bworld:watering_can", 1]]);
const can = last_container(t.take(1), "inventory").find((i: Msg) => i?.id === "bworld:watering_can");
const t = await setup([["bworld:copper_watering_can", 1]]);
const can = last_container(t.take(1), "inventory").find((i: Msg) => i?.id === "bworld:copper_watering_can");
assertEquals(can.data, { water: 0, max_water: 32 });
assertEquals(can.lore, "Water: 0/32");
// lore is worked out for players, it isn't saved
const saved = JSON.parse(t.game.save().level);
const saved_can = saved.players.alice?.inventory?.find((i: Msg) => i?.id === "bworld:watering_can");
const saved_can = saved.players.alice?.inventory?.find((i: Msg) => i?.id === "bworld:copper_watering_can");
assert(!saved_can || saved_can.lore === undefined);
t.game.on_disconnect(1);
const after = JSON.parse(t.game.save().level).players.alice.inventory.find((i: Msg) =>
i?.id === "bworld:watering_can"
i?.id === "bworld:copper_watering_can"
);
assertEquals(after.lore, undefined);
});
+3 -3
View File
@@ -41,7 +41,7 @@ async function setup(items: string[] = []) {
}
Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning", async () => {
const t = await setup(["bworld:wood_hoe", "bworld:watering_can", "bworld:wheat_seeds 4"]);
const t = await setup(["bworld:wood_hoe", "bworld:copper_watering_can", "bworld:wheat_seeds 4"]);
t.game.set_block(1, 100, 0, "bworld:grass");
t.game.set_block(0, 100, 1, "bworld:grass");
t.game.set_block(2, 100, 0, "bworld:water");
@@ -58,7 +58,7 @@ Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning"
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:wheat");
// a new can is empty, water fills it, and watering the crop waters the farmland under it
t.hold("bworld:watering_can");
t.hold("bworld:copper_watering_can");
t.take(1);
t.use(1, 101, 0);
assert(t.take(1).some((m) => m.type === "chat" && m.text.includes("empty")));
@@ -66,7 +66,7 @@ Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning"
t.use(2, 100, 0);
t.use(1, 101, 0);
assertEquals(t.state(1, 100, 0, "watered"), 1);
const can = t.inventory_now().find((i) => i?.id === "bworld:watering_can");
const can = t.inventory_now().find((i) => i?.id === "bworld:copper_watering_can");
assertEquals(can?.data, { water: 31, max_water: 32 });
// nothing happens during the day
+27 -8
View File
@@ -27,17 +27,17 @@ Deno.test("the base game loads from mods/bworld", async () => {
const bworld = (entries: [string, unknown][]) => entries.filter(([id]) => id.startsWith("bworld:")).length;
// 7 kinds of log, planks and leaves
assertEquals(bworld(EverythingRegistry.entries("blocks")), 42);
// 38 items (20 of them tools) plus the item forms of the 37 blocks that have one
assertEquals(bworld(EverythingRegistry.entries("items")), 75);
// bworld's 16 (4 wood tools, 7 planks, the fishing rod), the cooking pot, stove, cutting board and wood knife are
// farmersdelight's
assertEquals(game.recipes.shaped.length, 20);
// every log and fish smelts, every log burns
assertEquals(game.recipes.furnace.size, 14);
// 42 items (25 of them tools) plus the item forms of the 37 blocks that have one
assertEquals(bworld(EverythingRegistry.entries("items")), 79);
// bworld's 18 (4 wood tools, the wood watering can, 7 planks, the fishing rod, the smithing table), the cooking pot,
// stove, cutting board and wood knife are farmersdelight's
assertEquals(game.recipes.shaped.length, 22);
// every log and fish smelts, every log burns, and so do sand into glass and cobblestone into stone
assertEquals(game.recipes.furnace.size, 16);
assertEquals(game.recipes.fuel.size, 8);
assertEquals(EverythingRegistry.get<BlockRegistry>("blocks", "bworld:water")?.replaceable, true);
// still has its code until it's a component
assert(EverythingRegistry.get<ItemRegistry>("items", "bworld:watering_can")?.on_create);
assert(EverythingRegistry.get<ItemRegistry>("items", "bworld:copper_watering_can")?.on_create);
});
Deno.test("mods/bworld json survives going to the registry and back", async () => {
@@ -242,6 +242,25 @@ Deno.test("every tier of pickaxe, axe, shovel and hoe exists and can be made", a
}
});
Deno.test("every tier of watering can exists, can be made and holds more than the last", async () => {
const { game } = await test_game("mods");
const made = new Set([
...game.recipes.shaped.map((recipe) => recipe.result.id),
...game.recipes.smithing.map((recipe) => recipe.result),
]);
let last = 0;
for (const tier of ["wood", "stone", "copper", "iron", "gold"]) {
const id = `bworld:${tier}_watering_can`;
const item = EverythingRegistry.get<ItemRegistry>("items", id);
assertEquals(item?.tool?.type, "watering_can", id);
assertEquals(item?.texture_id, id);
assert(made.has(id), `nothing makes ${id}`);
const max_water = (item?.components?.["bworld:watering_can"] as { max_water: number }).max_water;
assert(max_water > last, id);
last = max_water;
}
});
Deno.test("a lit furnace shows its lit front", async () => {
await test_game("mods");
const furnace = EverythingRegistry.get<BlockRegistry>("blocks", "bworld:furnace")!;