Little drifting spirits of frost that come out on cold nights, over the snowfields, the pine woods and the mountains, wherever you're out under the sky in survival. They circle you, then dart in for a chilly touch: it stings, and for a while you heal slowly. A torch, lantern or campfire keeps them off, and they melt at sunrise. Two bops pop one, and it leaves a frost shard, which a Moon bell takes. None on a Peaceful world, and fewer on a Gentle one.
| 1 | --!strict |
| 2 | -- Frostwisps' own tests: `potluck-server --test=frostwisps`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.30") |
| 5 | |
| 6 | local function wisps(): { number } |
| 7 | return world.creatures(test.kind("Frostwisp")) |
| 8 | end |
| 9 | |
| 10 | -- somewhere out past the island whose land is one of these |
| 11 | local function find(lands: { [string]: boolean }): vector |
| 12 | local g = world.spot("green") |
| 13 | for r = 400, 4000, 150 do |
| 14 | for i = 0, 31 do |
| 15 | local a = i / 32 * 2 * math.pi |
| 16 | local at = vector.create(math.floor(g.x + math.cos(a) * r) + 0.5, 0, math.floor(g.z + math.sin(a) * r) + 0.5) |
| 17 | if lands[world.biome(at)] then |
| 18 | return at |
| 19 | end |
| 20 | end |
| 21 | end |
| 22 | error("no such land near the island") |
| 23 | end |
| 24 | |
| 25 | -- a player in survival standing on the ground out there |
| 26 | local function out_in(p, lands: { [string]: boolean }): vector |
| 27 | local at = find(lands) |
| 28 | test.move(p, vector.create(at.x, world.top(at.x, at.z) + 1, at.z)) |
| 29 | local there = vector.create(at.x, world.top(at.x, at.z) + 1.02, at.z) |
| 30 | test.move(p, there) |
| 31 | return there |
| 32 | end |
| 33 | |
| 34 | test.case("on a cold night frostwisps come, chill you and melt at sunrise", function() |
| 35 | test.danger("normal") |
| 36 | test.daytime(0) |
| 37 | local p = test.player("Ada", { survival = true }) |
| 38 | out_in(p, { snowfield = true }) |
| 39 | test.wait(14) |
| 40 | test.check(#wisps() >= 1, "frostwisps came") |
| 41 | test.wait(30) |
| 42 | test.check(test.health(p) < 20, "and one touched") |
| 43 | test.daytime(0.4) |
| 44 | test.wait(3) |
| 45 | test.same(#wisps(), 0, "melted at sunrise") |
| 46 | end) |
| 47 | |
| 48 | test.case("none by a lantern, none in warm lands, none on Peaceful", function() |
| 49 | test.danger("hard") |
| 50 | test.daytime(0) |
| 51 | local p = test.player("Ada", { survival = true }) |
| 52 | local at = out_in(p, { snowfield = true }) |
| 53 | world.set_block(at + vector.create(1, 0, 0), "Lantern") |
| 54 | test.wait(14) |
| 55 | test.same(#wisps(), 0, "none by the lantern") |
| 56 | world.set_block(at + vector.create(1, 0, 0), "Air") |
| 57 | test.danger("peaceful") |
| 58 | test.wait(10) |
| 59 | test.same(#wisps(), 0, "none on Peaceful") |
| 60 | test.danger("hard") |
| 61 | out_in(p, { desert = true }) |
| 62 | test.wait(14) |
| 63 | test.same(#wisps(), 0, "none in the desert") |
| 64 | end) |
| 65 | |
| 66 | test.case("two bops pop one, and it leaves a frost shard", function() |
| 67 | test.danger("normal") |
| 68 | test.daytime(0) |
| 69 | local p = test.player("Ada", { survival = true }) |
| 70 | local at = out_in(p, { snowfield = true }) |
| 71 | local id = world.spawn(test.kind("Frostwisp"), at + vector.create(2, 1.5, 0)) |
| 72 | test.wait(0.2) |
| 73 | test.hit(p, test.creature(id)) |
| 74 | test.check(test.creature(id) ~= nil, "one bop doesn't") |
| 75 | test.hit(p, test.creature(id)) |
| 76 | test.same(test.creature(id), nil, "two do") |
| 77 | test.check(world.has(p, "Frost shard") >= 1, "a frost shard") |
| 78 | test.same(world.xp(p), 4, "and some XP") |
| 79 | end) |