Things worth doing, to light your way through the island: dig your first ore, smelt it, cook and brew, trade with a village, wake the Gloam, cross the mirror into the Long Dusk. Open Goals from the pause menu to see what's done and what's next; each one done says so with a chime, and gives XP in survival. Other creations can list goals of their own with world.goals.
| 1 | --!strict |
| 2 | -- The goals' own tests: `potluck-server --test=goals`. |
| 3 | |
| 4 | local test = require("@potluck/test@0.9") |
| 5 | local world = require("@potluck/world@0.36") |
| 6 | |
| 7 | test.case("mining a coal ore and using a table are done by what the player does", function() |
| 8 | local p = test.player("Ada") |
| 9 | local at = vector.create(p.position.x + 3, world.top(p.position.x + 3, p.position.z) + 1, p.position.z) |
| 10 | test.check(not world.achieved(p, "coal"), "not yet") |
| 11 | test.place(p, at, "Coal ore") |
| 12 | test.dig(p, at) |
| 13 | test.wait(0.5) |
| 14 | test.check(world.achieved(p, "coal"), "breaking coal ore is a goal") |
| 15 | test.use_block(p, at) |
| 16 | test.place(p, at, "Table") |
| 17 | test.use_block(p, at) |
| 18 | test.wait(0.5) |
| 19 | test.check(world.achieved(p, "table"), "using a table is a goal") |
| 20 | test.check(not world.achieved(p, "iron"), "iron is still to do") |
| 21 | end) |
| 22 | |
| 23 | test.case("a wildcard matches any color of bed", function() |
| 24 | local p = test.player("Bea") |
| 25 | local at = vector.create(p.position.x + 3, world.top(p.position.x + 3, p.position.z) + 1, p.position.z) |
| 26 | test.place(p, at, "Red bed") |
| 27 | test.use_block(p, at) |
| 28 | test.wait(0.5) |
| 29 | test.check(world.achieved(p, "bed"), "any bed") |
| 30 | end) |
| 31 | |
| 32 | test.case("what a survival player carries is looked at", function() |
| 33 | local p = test.player("Cy", { survival = true, carrying = { ["Iron ingot"] = 1, ["Oak log"] = 2 } }) |
| 34 | test.wait(3) |
| 35 | test.check(world.achieved(p, "iron_ingot"), "an iron ingot") |
| 36 | test.check(world.achieved(p, "timber"), "a log") |
| 37 | test.check(not world.achieved(p, "copper_ingot"), "no copper ingot") |
| 38 | end) |
| 39 | |
| 40 | test.case("where a player is counts, and a goal is only done once", function() |
| 41 | local p = test.player("Di") |
| 42 | test.move(p, vector.create(p.position.x, -40, p.position.z)) |
| 43 | test.wait(3) |
| 44 | test.check(world.achieved(p, "cave"), "below 30") |
| 45 | test.check(not world.achieved(p, "vault_depth"), "not below 80") |
| 46 | test.check(not world.achieve(p, "cave"), "the second time says nothing new") |
| 47 | end) |
| 48 | |
| 49 | test.case("a survival player gets the goal's XP once", function() |
| 50 | local p = test.player("Eli", { survival = true }) |
| 51 | local before = world.xp(p) |
| 52 | test.check(world.achieve(p, "level5") == true, "done") |
| 53 | local after = world.xp(p) |
| 54 | test.check(after - before == 10, "XP given: " .. tostring(after - before)) |
| 55 | world.achieve(p, "level5") |
| 56 | test.same(world.xp(p), after, "not twice") |
| 57 | end) |