Little fiery things that flit about the deep caverns, far below the ground. They keep their distance and throw embers at anyone in survival: an ember stings, and where it lands it may start a small fire. Pop one with two bops, or better an arrow, and it leaves an ember, which burns in a furnace and lights a fire like flint and steel. None on a Peaceful world, and fewer on a Gentle one.
| 1 | --!strict |
| 2 | local test = require("@potluck/test@0.7") |
| 3 | local world = require("@potluck/world@0.22") |
| 4 | |
| 5 | local function imps(): { number } |
| 6 | return world.creatures(test.kind("Ember Imp")) |
| 7 | end |
| 8 | |
| 9 | -- a cavern dug out deep under where a player stands, a row at a time (a |
| 10 | -- whole cavern of blocks at once is more than one tick's work) |
| 11 | local function cavern(p): vector |
| 12 | local x, z, y = math.floor(p.position.x), math.floor(p.position.z), -70 |
| 13 | for dx = -12, 12 do |
| 14 | for dz = -12, 12 do |
| 15 | world.set_block(vector.create(x + dx, y - 1, z + dz), "Stone") |
| 16 | for dy = 0, 6 do |
| 17 | world.set_block(vector.create(x + dx, y + dy, z + dz), "Air") |
| 18 | end |
| 19 | end |
| 20 | test.wait(0) |
| 21 | end |
| 22 | return vector.create(x + 0.5, y, z + 0.5) |
| 23 | end |
| 24 | |
| 25 | test.case("deep down, imps come and throw embers", function() |
| 26 | test.danger("normal") |
| 27 | local p = test.player("Ada", { survival = true }) |
| 28 | local at = cavern(p) |
| 29 | test.move(p, at) |
| 30 | test.wait(14) |
| 31 | test.check(#imps() >= 1, "imps came") |
| 32 | test.wait(14) |
| 33 | test.check(test.health(p) < 20, "and an ember stung") |
| 34 | end) |
| 35 | |
| 36 | test.case("none on a Peaceful world, and none near the top", function() |
| 37 | test.danger("peaceful") |
| 38 | local p = test.player("Ada", { survival = true }) |
| 39 | local at = cavern(p) |
| 40 | test.move(p, at) |
| 41 | test.wait(10) |
| 42 | test.same(#imps(), 0, "none on Peaceful") |
| 43 | test.danger("hard") |
| 44 | test.move(p, vector.create(at.x, world.top(at.x, at.z) + 1, at.z)) |
| 45 | test.wait(10) |
| 46 | test.same(#imps(), 0, "none up top") |
| 47 | end) |
| 48 | |
| 49 | test.case("two bops pop one, and it leaves an ember", function() |
| 50 | test.danger("normal") |
| 51 | local p = test.player("Ada", { survival = true }) |
| 52 | local at = cavern(p) |
| 53 | test.move(p, at) |
| 54 | local id = world.spawn(test.kind("Ember Imp"), at + vector.create(2, 1, 0)) |
| 55 | test.wait(0.2) |
| 56 | test.hit(p, test.creature(id)) |
| 57 | test.hit(p, test.creature(id)) |
| 58 | test.same(test.creature(id), nil, "popped") |
| 59 | test.check(world.has(p, "Ember") >= 1, "an ember") |
| 60 | test.same(world.xp(p), 4, "and some XP") |
| 61 | end) |