Sign in
world

Moonsilver Vaults

by Potluck · version 1 · Checked for all ages

Far down in the slate, where the moonsilver runs, the old stone people built vaults: pillared halls of pale moonstone, lit by lanterns that have never gone out, with veins of moonsilver in the walls that Stone Sentinels still guard. At the far end a moon seal closes the sanctum. It has a round hollow the size of a sentinel's core. Inside lies the best gear on the island: moonsilver, a moonblade and a moon crown, and now and then a star chart for the Curator.

1--!strict
2-- Moonsilver Vaults' own tests: `potluck-server --test=moonsilver-vault`.
3
4local test = require("@potluck/test@0.8")
5local world = require("@potluck/world@0.26")
6local store = require("@potluck/store")
7
8-- the tools creation gives pickaxes their levels; these tests don't run it
9world.digging("Moonsilver pickaxe", { hard = 8, level = 5 })
10
11local function v(x: number, y: number, z: number): vector
12 return vector.create(x, y, z)
13end
14
15-- a little cave dug far down in the slate, far from the Green, for a player
16-- to stand in, and the vault that opens near them
17local function down_deep(p): any
18 local g = world.spot("green") :: vector
19 local x, y, z = math.floor(g.x) - 130, -96, math.floor(g.z) + 60
20 for dx = -2, 2 do
21 for dz = -2, 2 do
22 for dy = 0, 2 do
23 world.set_block(v(x + dx, y + dy, z + dz), "Air")
24 end
25 world.set_block(v(x + dx, y - 1, z + dz), "Slate")
26 end
27 end
28 test.move(p, v(x + 0.5, y, z + 0.5))
29 for _ = 1, 40 do
30 test.wait(1)
31 local list = store.get("vaults") :: { any }?
32 if list and list[1] and list[1].built then
33 return list[1]
34 end
35 end
36 return nil
37end
38
39-- what a player carries, all told
40local function carried(p): number
41 local n = 0
42 for _, c in world.pockets(p) or {} do
43 n += c
44 end
45 return n
46end
47
48test.case("a vault opens far down near a player: a pillared hall of moonstone, veined with moonsilver, sealed at its end", function()
49 local p = test.player("Ada")
50 local w = down_deep(p)
51 test.check(w ~= nil, "a vault opened")
52 local at = w.at :: vector
53 test.same(world.block(at), "Air", "it's dug")
54 test.same(world.block(at - v(0, 1, 0)), "Moonstone", "floored with moonstone")
55 test.same(world.block(at + v(3, 2, 0)), "Column", "pillars")
56 test.same(world.block(at + v(-5, 3, 2)), "Lantern", "lanterns in the walls")
57 test.same(world.block(at + v(0, 0, -8)), "Moon seal", "the seal")
58 test.same(world.block(at + v(0, 1, -8)), "Moon seal", "two blocks high")
59 test.same(world.block(at + v(0, 0, -10)), "Moonsilver coffer", "the coffer behind it")
60 for _, d in { v(0, 0, -12), v(2, 0, -10), v(-2, 1, -10), v(0, 3, -10), v(0, -1, -10), v(1, 0, -8) } do
61 test.same(world.block(at + d), "Moonstone", "the sanctum's all moonstone")
62 end
63 local ore = 0
64 for x = -5, 5 do
65 for z = -8, 8 do
66 for y = 0, 5 do
67 if world.block(at + v(x, y, z)) == "Moonsilver ore" then
68 ore += 1
69 end
70 end
71 end
72 end
73 test.check(ore >= 6, "moonsilver in the walls, for sentinels to guard: " .. ore)
74 test.same(w.open, false, "sealed")
75 test.wait(6)
76 test.same(#(store.get("vaults") :: { any }), 1, "only one")
77end)
78
79test.case("nothing cuts moonstone or the seal", function()
80 local p = test.player("Ada", { survival = true, carrying = { ["Moonsilver pickaxe"] = 1 } })
81 test.hold(p, "Moonsilver pickaxe")
82 local x, z = p.position.x + 2, p.position.z
83 local y = world.top(x, z) + 1
84 local stone, seal = v(x, y, z), v(x, y, z + 1)
85 world.set_block(stone, "Moonstone")
86 world.set_block(seal, "Moon seal")
87 test.check(not test.dig(p, stone), "not moonstone")
88 test.check(not test.dig(p, seal), "nor the seal")
89end)
90
91test.case("a sentinel core opens the seal for good, and the coffer gives the best gear once", function()
92 test.danger("normal")
93 local p = test.player("Ada", { survival = true, carrying = { ["Sentinel core"] = 1 } })
94 local w = down_deep(p)
95 test.check(w ~= nil, "a vault")
96 local at = w.at :: vector
97 local seal = at + v(0, 0, -8)
98 test.move(p, at + v(0.5, 0, -6.5))
99 test.wait(1)
100 test.same(test.shown(p, "vault"), "A moonsilver vault. The seal at its end is shut.", "a word on coming in")
101 -- nothing in hand
102 test.use_block(p, seal)
103 test.same(test.shown(p, "vault"), "A round hollow, the size of a sentinel core.")
104 test.same(world.block(seal), "Moon seal", "still shut")
105 test.hold(p, "Sentinel core")
106 test.use_block(p, seal)
107 test.same(world.block(seal), "Air", "it rolls away")
108 test.same(world.block(seal + v(0, 1, 0)), "Air", "both blocks")
109 test.same(world.has(p, "Sentinel core"), 0, "taking the core")
110 test.same(test.heard("seal"), 1, "with its sound")
111 test.same((store.get("vaults") :: { any })[1].open, true, "kept open")
112 local before = carried(p)
113 test.move(p, at + v(0.5, 0, -8.5))
114 test.use_block(p, at + v(0, 0, -10))
115 test.check(carried(p) > before, "the coffer's treasure")
116 test.same(test.shown(p, "vault"), "The old stone people's treasure is yours.")
117 local card = test.asked(p) :: any
118 test.check(card ~= nil and string.find(card.text, "You found", 1, true) == 1, "what's in it")
119 test.answer(p, 1)
120 test.use_block(p, at + v(0, 0, -10))
121 test.same(test.shown(p, "vault"), "An empty coffer.")
122end)
123
124test.case("on a Peaceful world, three moonsilver ingots open the seal", function()
125 test.danger("peaceful")
126 local p = test.player("Ada", { survival = true, carrying = { ["Moonsilver ingot"] = 4 } })
127 local w = down_deep(p)
128 test.check(w ~= nil, "a vault")
129 local seal = w.at + v(0, 0, -8)
130 test.move(p, w.at + v(0.5, 0, -6.5))
131 test.wait(1)
132 test.use_block(p, seal)
133 test.same(test.shown(p, "vault"), "It wants three moonsilver ingots, or a sentinel core.")
134 test.hold(p, "Moonsilver ingot")
135 test.use_block(p, seal)
136 test.same(world.block(seal), "Air", "open")
137 test.same(world.has(p, "Moonsilver ingot"), 1, "three taken")
138end)
139
140test.case("the moonblade hits hardest, the moon crown guards best, and the star chart is a relic", function()
141 local blade = world.item("Moonblade") :: any
142 test.same(blade.kind, "weapon")
143 test.check(blade.power > 5, "harder than a moonsilver sword")
144 local crown = world.item("Moon crown") :: any
145 test.same(crown.kind, "armor")
146 test.same(crown.slot, "head")
147 test.check(crown.guard > 3 and crown.warm == true, "better than a moonsilver helmet, and warm")
148 local chart = world.item("Star chart") :: any
149 test.check(chart ~= nil and chart.by == "moonsilver-vault", "an item of the vaults'")
150 test.check(type(chart.relic) == "string" and #chart.relic > 20, "its story")
151end)