Heaps of peat and reeds that heave up out of the ground on dark nights, wherever you're out under the sky in survival with no light about. They're slow but they hit hard, and they sink back into the ground at sunrise. A lantern, torch or campfire keeps them from rising near you. They're earth, so a shovel breaks them up twice as fast, and a broken bogle leaves peat, which burns long in a furnace. None on a Peaceful world, and fewer on a Gentle one.
| 1 | --!strict |
| 2 | -- Bogles' own tests: `potluck-server --test=bogles`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.25") |
| 5 | |
| 6 | -- a grassy field high in the sky, well away from the Green and its lights: |
| 7 | -- where a player stands on it |
| 8 | local function field(): vector |
| 9 | local g = world.spot("green") |
| 10 | local cx, cz, y = math.floor(g.x) + 90, math.floor(g.z), 90 |
| 11 | for dx = -24, 24 do |
| 12 | for dz = -24, 24 do |
| 13 | world.set_block(vector.create(cx + dx, y, cz + dz), "Grass") |
| 14 | end |
| 15 | test.wait(0) |
| 16 | end |
| 17 | return vector.create(cx + 0.5, y + 1, cz + 0.5) |
| 18 | end |
| 19 | |
| 20 | local function bogles(): { number } |
| 21 | local out = {} |
| 22 | for _, k in { "Bogle", "Bogle (rising)" } do |
| 23 | for _, id in world.creatures(test.kind(k)) do |
| 24 | table.insert(out, id) |
| 25 | end |
| 26 | end |
| 27 | return out |
| 28 | end |
| 29 | |
| 30 | test.case("on a dark night bogles rise, come for you, and sink at sunrise", function() |
| 31 | test.danger("normal") |
| 32 | test.daytime(0) |
| 33 | local p = test.player("Ada", { survival = true }) |
| 34 | test.move(p, field()) |
| 35 | test.wait(12) |
| 36 | test.check(#bogles() >= 1, "bogles rose") |
| 37 | test.wait(25) |
| 38 | test.check(test.health(p) < 20, "and one hit") |
| 39 | test.daytime(0.4) |
| 40 | test.wait(6) |
| 41 | test.same(#bogles(), 0, "gone at sunrise") |
| 42 | end) |
| 43 | |
| 44 | test.case("none by a lantern, none on Peaceful", function() |
| 45 | test.danger("normal") |
| 46 | test.daytime(0) |
| 47 | local p = test.player("Ada", { survival = true }) |
| 48 | local at = field() |
| 49 | test.move(p, at) |
| 50 | world.set_block(at + vector.create(1, 0, 0), "Lantern") |
| 51 | test.wait(16) |
| 52 | test.same(#bogles(), 0, "none rose by the lantern") |
| 53 | world.set_block(at + vector.create(1, 0, 0), "Air") |
| 54 | test.danger("peaceful") |
| 55 | test.wait(12) |
| 56 | test.same(#bogles(), 0, "none on Peaceful") |
| 57 | end) |
| 58 | |
| 59 | test.case("a shovel breaks one up faster, and it leaves peat", function() |
| 60 | test.danger("normal") |
| 61 | test.daytime(0) |
| 62 | local p = test.player("Ada", { survival = true, carrying = { ["Stone shovel"] = 1 } }) |
| 63 | local at = field() |
| 64 | test.move(p, at) |
| 65 | local id = world.spawn(test.kind("Bogle"), at + vector.create(2, 0, 0)) |
| 66 | test.wait(0.2) |
| 67 | test.hold(p, nil) |
| 68 | test.hit(p, test.creature(id)) |
| 69 | test.hit(p, test.creature(id)) |
| 70 | test.check(test.creature(id) ~= nil, "two bops by hand don't do it") |
| 71 | test.hold(p, "Stone shovel") |
| 72 | test.hit(p, test.creature(id)) |
| 73 | test.hit(p, test.creature(id)) |
| 74 | test.same(test.creature(id), nil, "a shovel does") |
| 75 | test.check(world.has(p, "Peat") >= 1, "peat") |
| 76 | test.same(world.xp(p), 5, "and some XP") |
| 77 | end) |