Add season for crops
This commit is contained in:
@@ -188,6 +188,9 @@ Deno.test("potatoes and carrots are planted on farmland, and eaten anywhere else
|
||||
|
||||
Deno.test("tomatoes take 11 days, are picked by hand, and grow back in 4", async () => {
|
||||
const t = await setup();
|
||||
// they only grow in summer, which starts on day 50
|
||||
t.game.set_time(49 * CYCLE_TICKS);
|
||||
t.game.tick();
|
||||
const ages = grow(t, 1, "farmersdelight:tomatoes", 11);
|
||||
assertEquals(ages.at(-1), 7);
|
||||
assertEquals(ages.at(-2), 6);
|
||||
@@ -240,3 +243,35 @@ Deno.test("rice is planted in water, grows panicles on top without watering, and
|
||||
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:water");
|
||||
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
|
||||
});
|
||||
|
||||
Deno.test("a crop dies into a dead bush the first morning out of its seasons", async () => {
|
||||
const t = await setup();
|
||||
// carrots grow in spring and autumn. the last morning of spring they grow
|
||||
t.game.set_time(47 * CYCLE_TICKS);
|
||||
t.game.tick();
|
||||
assertEquals(grow(t, 0, "bworld:carrots", 1), [1]);
|
||||
// and the first of summer they die, dropping nothing
|
||||
t.game.set_block_state(0, 100, 0, 1);
|
||||
t.next_morning();
|
||||
assertEquals(t.game.world.day, 49);
|
||||
assertEquals(t.game.world.get_block_id(0, 101, 0), "bworld:dead_bush");
|
||||
assertEquals(t.game.item_entities(), []);
|
||||
// still standing on its farmland
|
||||
assertEquals(t.game.world.get_block_id(0, 100, 0), "bworld:hoed_dirt");
|
||||
});
|
||||
|
||||
Deno.test("a two block crop dies whole, its top going without dropping anything", async () => {
|
||||
const t = await setup();
|
||||
t.game.set_block(1, 99, 0, "bworld:dirt");
|
||||
t.game.set_block(1, 100, 0, "farmersdelight:rice");
|
||||
for (let day = 0; day < 6; day++) t.next_morning();
|
||||
assertEquals(t.game.world.get_block_id(1, 101, 0), "farmersdelight:rice_panicles");
|
||||
|
||||
// rice grows in autumn, dies in winter, winter starts on day 148
|
||||
t.game.set_time(147 * CYCLE_TICKS - 1);
|
||||
t.game.tick();
|
||||
t.game.tick();
|
||||
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:dead_bush");
|
||||
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
|
||||
assertEquals(t.game.item_entities(), []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user