Old stone guardians that stand over the moonsilver deep in the earth. Come near their ore in survival and one wakes: slow, but it hits hard, and it's very tough. Beat it and it leaves a sentinel core, and sometimes moonsilver, and that seam is yours. Rare, and only far below the ground. None on a Peaceful world.
| 1 | --!strict |
| 2 | local test = require("@potluck/test@0.7") |
| 3 | local world = require("@potluck/world@0.21") |
| 4 | |
| 5 | local function sentinels(): { number } |
| 6 | return world.creatures(test.kind("Stone Sentinel")) |
| 7 | end |
| 8 | |
| 9 | -- a cave deep down with moonsilver in its wall: where to stand, and the ore |
| 10 | local function seam(p): (vector, vector) |
| 11 | local x, z, y = math.floor(p.position.x), math.floor(p.position.z), -100 |
| 12 | for dx = -10, 10 do |
| 13 | for dz = -10, 10 do |
| 14 | world.set_block(vector.create(x + dx, y - 1, z + dz), "Stone") |
| 15 | for dy = 0, 3 do |
| 16 | world.set_block(vector.create(x + dx, y + dy, z + dz), "Air") |
| 17 | end |
| 18 | end |
| 19 | test.wait(0) |
| 20 | end |
| 21 | local ore = vector.create(x + 8, y, z) |
| 22 | world.set_block(ore, "Moonsilver ore") |
| 23 | return vector.create(x - 6 + 0.5, y, z + 0.5), ore |
| 24 | end |
| 25 | |
| 26 | test.case("a sentinel stands over moonsilver, and wakes when you come close", function() |
| 27 | test.danger("normal") |
| 28 | local p = test.player("Ada", { survival = true }) |
| 29 | local at, ore = seam(p) |
| 30 | test.move(p, at) |
| 31 | test.wait(8) |
| 32 | test.same(#sentinels(), 1, "one stands guard") |
| 33 | test.wait(4) |
| 34 | test.same(test.health(p), 20, "asleep while you keep off") |
| 35 | test.move(p, ore + vector.create(-2, 0, 0.5)) |
| 36 | test.wait(8) |
| 37 | test.check(test.health(p) < 20, "awake, it slams") |
| 38 | end) |
| 39 | |
| 40 | test.case("none on a Peaceful world", function() |
| 41 | test.danger("peaceful") |
| 42 | local p = test.player("Ada", { survival = true }) |
| 43 | local at, ore = seam(p) |
| 44 | test.move(p, ore + vector.create(-2, 0, 0.5)) |
| 45 | test.wait(10) |
| 46 | test.same(#sentinels(), 0, "none") |
| 47 | end) |
| 48 | |
| 49 | test.case("beaten, it leaves a sentinel core, and that seam stays unguarded", function() |
| 50 | test.danger("gentle") |
| 51 | local p = test.player("Ada", { survival = true, carrying = { ["Iron sword"] = 1 } }) |
| 52 | local at, ore = seam(p) |
| 53 | test.move(p, at) |
| 54 | test.hold(p, "Iron sword") |
| 55 | test.wait(8) |
| 56 | local id = sentinels()[1] |
| 57 | test.check(id ~= nil, "one stands guard") |
| 58 | for _ = 1, 3 do |
| 59 | test.hit(p, test.creature(id)) |
| 60 | end |
| 61 | test.check(test.creature(id) ~= nil, "tough") |
| 62 | test.hit(p, test.creature(id)) |
| 63 | test.same(test.creature(id), nil, "beaten") |
| 64 | test.same(world.has(p, "Sentinel core"), 1, "a core") |
| 65 | test.wait(12) |
| 66 | test.same(#sentinels(), 0, "and no other comes") |
| 67 | end) |