Sign in
world

The Deep Kitchen

by Potluck · version 1 · Checked for all ages

Long ago the island's first potluck was held in a feast hall that's now deep under the ground. Wander far enough down and you may break into it: long tables laid with candles, a hearth with its cooking pot, a larder and a shelf of old recipes. Each recipe card teaches the cooking pot a dish found nowhere else, from glowcap soup to potluck stew, as long as you carry it. And somewhere on the shelf is the menu from that first potluck, for the Curator.

1--!strict
2-- The Deep Kitchen's own tests: `potluck-server --test=deep-kitchen`. The
3-- Furnaces aren't here, so the hearth is a brazier and there's no pot; a
4-- Rust test (`deep_kitchen_cards_teach_the_cooking_pot`) cooks its dishes
5-- with the Furnaces running too.
6
7local test = require("@potluck/test@0.8")
8local world = require("@potluck/world@0.27")
9local store = require("@potluck/store")
10
11local DISHES = { "Glowcap soup", "Miner's pasty", "Honey carrots", "Feast pie", "Potluck stew" }
12
13local function v(x: number, y: number, z: number): vector
14 return vector.create(x, y, z)
15end
16
17-- a little cave dug in the rock under the island, far from the Green, for
18-- a player to stand in, and the kitchen that opens near them
19local function down_deep(p): any
20 local g = world.spot("green") :: vector
21 local x, y, z = math.floor(g.x) - 150, -24, math.floor(g.z) + 60
22 for dx = -2, 2 do
23 for dz = -2, 2 do
24 for dy = 0, 2 do
25 world.set_block(v(x + dx, y + dy, z + dz), "Air")
26 end
27 world.set_block(v(x + dx, y - 1, z + dz), "Stone")
28 end
29 end
30 test.move(p, v(x + 0.5, y, z + 0.5))
31 for _ = 1, 40 do
32 test.wait(1)
33 local list = store.get("kitchens") :: { any }?
34 if list and list[1] and list[1].built then
35 return list[1]
36 end
37 end
38 return nil
39end
40
41test.case("a feast hall opens deep underground near a player, with a long table and a shelf of recipes", function()
42 local p = test.player("Ada")
43 local k = down_deep(p)
44 test.check(k ~= nil, "a kitchen opened")
45 local at = k.at :: vector
46 test.same(world.block(at), "Table", "the long table down the middle")
47 test.same(world.block(at + v(4, 0, 0)), "Table", "it's long")
48 test.same(world.block(at + v(0, 0, 1)), "Stool", "stools along it")
49 test.same(world.block(at + v(0, 1, 0)), "Candle", "candles on it")
50 test.same(world.block(at - v(0, 1, 0)), "Planks", "on a plank floor")
51 test.same(world.block(at + v(8, 1, 0)), "Sandstone bricks", "in sandstone walls")
52 for i = 1, 5 do
53 test.same(world.block(at + v(-6 + i * 2, 0, -4)), "Bookshelf", "a recipe shelf")
54 end
55 -- the Furnaces' cooking pot over its campfire when they're in this
56 -- world (as when every base creation's tests share one game), else a brazier
57 local hearth = if pcall(world.kind, "Cooking pot") then "Cooking pot" else "Brazier"
58 test.same(world.block(at + v(7, 0, 0)), hearth, "the hearth")
59 test.same(world.block(at + v(-7, 0, -2)), "Barrel", "the larder")
60 test.same(#k.cards, 5, "five cards")
61 test.move(p, at + v(0.5, 0, -2.5))
62 test.wait(1)
63 test.same(test.shown(p, "kitchen"), "A feast hall, buried long ago. Its shelf holds old recipes.")
64end)
65
66test.case("each shelf gives its recipe card once, and one may hold the first potluck's menu", function()
67 local p = test.player("Ada", { survival = true })
68 local k = down_deep(p)
69 test.check(k ~= nil, "a kitchen")
70 local at = k.at :: vector
71 local menu = k.menu
72 test.move(p, at + v(0.5, 0, -2.5))
73 for i = 1, 5 do
74 test.use_block(p, at + v(-6 + i * 2, 0, -4))
75 local q = test.asked(p)
76 test.check(q ~= nil and string.find(q.text, "recipe card", 1, true) ~= nil, "a card on shelf " .. i)
77 test.answer(p, 1)
78 end
79 for _, dish in DISHES do
80 test.same(world.has(p, dish .. " recipe"), 1, "the " .. dish .. " card")
81 end
82 test.same(world.has(p, "First potluck menu"), if menu > 0 then 1 else 0, "the menu, if this kitchen kept one")
83 test.check((world.xp(p)) >= 15, "some XP for them")
84 test.use_block(p, at + v(-4, 0, -4))
85 test.same(test.shown(p, "kitchen"), "Only crumbs and faded pages now.")
86 test.same(world.has(p, DISHES[1] .. " recipe"), 1, "only once")
87end)
88
89test.case("breaking a shelf gives its card too", function()
90 local p = test.player("Ada", { survival = true })
91 local k = down_deep(p)
92 test.check(k ~= nil, "a kitchen")
93 local at = k.at :: vector
94 test.move(p, at + v(0.5, 0, -2.5))
95 test.check(test.dig(p, at + v(0, 0, -4)), "the middle shelf broken")
96 local cards = 0
97 for _, dish in DISHES do
98 cards += world.has(p, dish .. " recipe")
99 end
100 test.same(cards, 1, "its card")
101 test.same(world.has(p, "Bookshelf"), 1, "and the bookshelf")
102end)
103
104test.case("creative players can look around but take no cards", function()
105 local p = test.player("Cy")
106 local k = down_deep(p)
107 test.check(k ~= nil, "a kitchen")
108 local at = k.at :: vector
109 test.move(p, at + v(0.5, 0, -2.5))
110 test.wait(5.5)
111 test.use_block(p, at + v(-4, 0, -4))
112 test.same(test.shown(p, "kitchen"), "The recipe shelf holds its cards for survival.")
113 test.same((store.get("kitchens") :: { any })[1].cards[1], true, "the shelf keeps its card")
114end)
115
116test.case("the dishes are food a cooking pot cooks for a cook with the card", function()
117 for _, dish in DISHES do
118 local it = world.item(dish)
119 test.check(it ~= nil and it.kind == "food" and (it.food or 0) >= 8, dish .. " is food")
120 test.check(it ~= nil and it.cook ~= nil and it.card == dish .. " recipe", dish .. " cooks with its card")
121 end
122 local stew = world.item("Potluck stew") :: any
123 test.same(stew.makes, 6, "potluck stew feeds a crowd")
124 test.same(stew.cook.Glowcap, 1, "with a glowcap in it")
125end)
126
127test.case("a card read in hand says what its dish takes", function()
128 local p = test.player("Ada", { survival = true, carrying = { ["Glowcap soup recipe"] = 1 } })
129 test.hold(p, "Glowcap soup recipe")
130 test.use_item(p, v(0, 1, 0))
131 local q = test.asked(p)
132 test.check(q ~= nil and q.title == "Glowcap soup", "the card")
133 test.check(q ~= nil and string.find(q.text, "2 Glowcap", 1, true) ~= nil and string.find(q.text, "1 Milk bucket", 1, true) ~= nil, q and q.text or "")
134end)
135
136test.case("the first potluck menu is a relic, with its story", function()
137 local it = world.item("First potluck menu") :: any
138 test.check(it ~= nil and it.by == "deep-kitchen", "an item of the kitchen's")
139 test.check(type(it.relic) == "string" and string.find(it.relic, "stew", 1, true) ~= nil, "its story")
140end)