Waddling mushrooms that live in the dark of caves. Underground, they keep their distance from anyone in survival and lob puffs of spores at them, so watch for them coming and step aside. They keep out of the light, but they'll throw into it. Bop one up close and it puffs in your face: an arrow or a sling is better. A popped one leaves a puffcap, good to eat, and a cooking pot makes puffcaps into mushroom stew. None on a Peaceful world, and fewer on a Gentle one.
| 1 | --!strict |
| 2 | -- Puffcaps' own tests: `potluck-server --test=puffcaps`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.31") |
| 5 | |
| 6 | local function puffcaps(): { number } |
| 7 | return world.creatures(test.kind("Puffcap")) |
| 8 | end |
| 9 | |
| 10 | -- a cave dug out under where a player stands, a row at a time |
| 11 | local function cave(p): vector |
| 12 | local x, z, y = math.floor(p.position.x), math.floor(p.position.z), -24 |
| 13 | for dx = -14, 14 do |
| 14 | for dz = -14, 14 do |
| 15 | world.set_block(vector.create(x + dx, y - 1, z + dz), "Stone") |
| 16 | for dy = 0, 4 do |
| 17 | world.set_block(vector.create(x + dx, y + dy, z + dz), "Air") |
| 18 | end |
| 19 | world.set_block(vector.create(x + dx, y + 5, z + dz), "Stone") |
| 20 | end |
| 21 | test.wait(0) |
| 22 | end |
| 23 | return vector.create(x + 0.5, y, z + 0.5) |
| 24 | end |
| 25 | |
| 26 | test.case("in a dark cave, puffcaps keep their distance and lob spores", function() |
| 27 | test.danger("normal") |
| 28 | local p = test.player("Ada", { survival = true }) |
| 29 | local at = cave(p) |
| 30 | test.move(p, at) |
| 31 | test.wait(12) |
| 32 | test.check(#puffcaps() >= 1, "puffcaps came") |
| 33 | test.wait(30) |
| 34 | test.check(test.heard("puff") >= 1, "they puffed") |
| 35 | test.check(test.health(p) < 20, "and the spores stung") |
| 36 | for _, id in puffcaps() do |
| 37 | local c = test.creature(id) |
| 38 | test.check(vector.magnitude(c.position - p.position) > 3, "they keep their distance") |
| 39 | end |
| 40 | end) |
| 41 | |
| 42 | test.case("none on Peaceful, and none up top", function() |
| 43 | test.danger("peaceful") |
| 44 | local p = test.player("Ada", { survival = true }) |
| 45 | local at = cave(p) |
| 46 | test.move(p, at) |
| 47 | test.wait(10) |
| 48 | test.same(#puffcaps(), 0, "none on Peaceful") |
| 49 | test.danger("hard") |
| 50 | test.move(p, vector.create(at.x, world.top(at.x, at.z) + 1, at.z)) |
| 51 | test.wait(10) |
| 52 | test.same(#puffcaps(), 0, "none up top") |
| 53 | end) |
| 54 | |
| 55 | test.case("bopped by hand it puffs in your face, and popped it leaves a puffcap", function() |
| 56 | test.danger("normal") |
| 57 | local p = test.player("Ada", { survival = true }) |
| 58 | local at = cave(p) |
| 59 | test.move(p, at) |
| 60 | local id = world.spawn(test.kind("Puffcap"), at + vector.create(2, 0, 0)) |
| 61 | test.wait(0.2) |
| 62 | test.hit(p, test.creature(id)) |
| 63 | test.wait(0.2) |
| 64 | test.check(test.health(p) < 20, "a face full of spores") |
| 65 | test.hit(p, test.creature(id)) |
| 66 | test.same(test.creature(id), nil, "popped") |
| 67 | test.check(world.has(p, "Puffcap") >= 1, "a puffcap") |
| 68 | end) |