Sign in
creature

Goats

by Potluck · version 1 · Checked for all ages

Goats graze the hill and jump about for the fun of it. Hold wheat or carrots and they come to you. In survival, use a goat with a bucket in hand to milk it, for drinking or for cooking porridge, stews and honey cake in a cooking pot. Feed two goats and they have a kid, which grows into a goat.

1--!strict
2local test = require("@potluck/test@0.6")
3local world = require("@potluck/world@0.20")
4local store = require("@potluck/store")
5
6local function goats(): { number }
7 return world.creatures(test.kind("Goat"))
8end
9
10local function kids(): { number }
11 return world.creatures(test.kind("Kid"))
12end
13
14test.case("a goat gives milk into a bucket, and not again straight away", function()
15 local p = test.player("Ada", { survival = true, carrying = { Bucket = 2 } })
16 test.wait(1)
17 test.same(#goats(), 3, "goats")
18 test.hold(p, "Bucket")
19 local g = test.creature(goats()[1])
20 test.use(p, g)
21 test.same(world.has(p, "Milk bucket"), 1, "milk")
22 test.same(world.has(p, "Bucket"), 1, "one bucket left")
23 test.use(p, g)
24 test.same(world.has(p, "Milk bucket"), 1, "no more yet")
25 -- another goat has milk to give
26 test.use(p, test.creature(goats()[2]))
27 test.same(world.has(p, "Milk bucket"), 2, "milk from the next")
28end)
29
30test.case("two goats fed wheat have a kid, which grows up into a goat", function()
31 local p = test.player("Ada", { survival = true, carrying = { Wheat = 4 } })
32 test.wait(1)
33 test.hold(p, "Wheat")
34 local ids = goats()
35 test.use(p, test.creature(ids[1]))
36 test.use(p, test.creature(ids[2]))
37 test.same(world.has(p, "Wheat"), 2, "each ate one")
38 test.wait(25)
39 test.same(#kids(), 1, "a kid")
40 test.wait(16)
41 local kept = store.get("herd") or {}
42 test.same(#kept, 1, "the kid is kept with the world")
43 test.wait(300)
44 test.same(#kids(), 0, "no kid now")
45 test.same(#goats(), 4, "it's a goat")
46end)
47
48test.case("goats don't have kids unfed", function()
49 test.wait(60)
50 test.same(#kids(), 0, "no kids")
51end)