New crops

This commit is contained in:
2026-10-10 15:28:20 -03:00
parent 373d9f83e5
commit 6dc85ff17e
65 changed files with 478 additions and 0 deletions
+31
View File
@@ -275,3 +275,34 @@ Deno.test("a two block crop dies whole, its top going without dropping anything"
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.item_entities(), []);
});
Deno.test("beetroots, cotton and strawberries grow, and strawberries and cotton are picked and grow back", async () => {
const t = await setup();
// beetroots and strawberries grow in spring
assertEquals(grow(t, 0, "bworld:beetroots", 6), [1, 2, 3, 4, 5, 7]);
const strawberries = grow(t, 1, "bworld:strawberries", 8);
assertEquals(strawberries.at(-2), 4, "not grown a day early");
assertEquals(strawberries.at(-1), 5);
t.use(1, 101, 0);
const picked = t.game.item_entities().map((e) => e.item.to_data());
assertEquals(picked.map((item) => item.id), ["bworld:strawberry"]);
assertEquals(t.state(1, 101, 0, "age"), 2, "back to a young bush");
// cotton grows in summer, which starts on day 50
t.game.set_time(49 * CYCLE_TICKS);
t.game.tick();
assertEquals(grow(t, 2, "bworld:cotton", 10), [0, 1, 2, 2, 3, 4, 4, 5, 6, 7]);
// picked like strawberries, it grows back in 3 days
t.use(2, 101, 0);
const cotton = t.game.item_entities().map((e) => e.item.to_data()).filter((item) => item.id === "bworld:cotton");
assertEquals(cotton.length, 1);
assert(cotton[0].count >= 1 && cotton[0].count <= 2);
assertEquals(t.state(2, 101, 0, "age"), 4, "back to a young plant");
assertEquals(t.game.world.get_block_id(2, 101, 0), "bworld:cotton", "the plant stays");
for (let day = 0; day < 3; day++) {
t.game.set_block_state(2, 100, 0, 1);
t.next_morning();
}
assertEquals(t.state(2, 101, 0, "age"), 7);
});