-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.js
404 lines (396 loc) · 17.6 KB
/
world.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
const WARNING_LINES = [
"This place is a message... and part of a system of messages... pay attention to it!",
"Sending this message was important to us. We considered ourselves to be a powerful culture.",
"This place is not a place of honor... no highly esteemed deed is commemorated here... nothing valued is here.",
"What is here was dangerous and repulsive to us. This message is a warning about danger.",
"The danger is in a particular location... it increases towards a center... the center of danger is here... of a particular size and shape, and below us.",
"The danger is still present, in your time, as it was in ours.",
"The danger is to the body, and it can kill.",
"The form of the danger is an emanation of energy.",
"The danger is unleashed only if you substantially disturb this place physically. This place is best shunned and left uninhabited.",
];
const INFOCENTER_PANEL1 = [
...WARNING_LINES.slice(0, 2),
"not - place -- honor",
...WARNING_LINES.slice(3),
];
/*
* items: mapping of itemId -> Item
* Item: mapping of:
* aliases: list of strings; alternative names that can be used to refer to this item.
* moveable: whether this can be moved.
* TODO: Unused.
* writing: Text to display as writing on this item.
* rosetta: (String of) Text that is translated on this panel. Percieving the panel may add these to knowledge.
* writtenWords: (String of) Text that the player has written on this item. Words are appended to this string
* with the "write" command from the player.
* passive: Sense table, presented passively (i.e. when just looking at the room / container.)
* These should be sentence fragments -- they fit into the list.
* sense: Sense table, presented actively (i.e. when specifically looking at this item)
* These should be complete paragraphs -- they are presented on their own,
* so they should include the item itself.
* location: roomId where this item is.
* TODO: Or something other than a room ID?
* action: Additional actions that can be performed on this item. List of objects:
* aliases: List of strings that this action matches.
* callback: function(item, State) to update the state of the game.
* Returns an error string, if there is an error.
* lightLevel: light level emitted by this item. Defaults to 0.
* write: Text to display when this item is written to.
*
* rooms: mapping of roomId -> Room
* Room: mapping of:
* exits: mapping of string -> roomId.
* rad_rate: ambient radiation in the room, rads per second.
* senses: Sense table.
* droneVolume: drone volume adjustment (typically negative, deciBels)
* lightLevel: ambient light level. Mutable, saved; defaults to 0 if unspecified.
*
* Sense table: mapping of sense (canonical) to description.
*/
/// Implementation of the light switch in the hot cell.
function hotCellLightSwitch(_self, state) {
console.log("flipping lightswitch");
// light to room, on this circuit
const MAPPINGS = {
"hot cell light": "hot cell",
};
for (const [itemId, roomId] of Object.entries(MAPPINGS)) {
if (state.rooms[roomId].itemIds.has(itemId)) {
state.rooms[roomId].itemIds.delete(itemId);
} else {
state.rooms[roomId].itemIds.add(itemId);
}
}
state.currentDescription = "The cylinder pivots across its base, and clicks.";
}
function flashlightSwitch(self, state) {
self.lightLevel = self.lightLevel === 1 ? 0 : 1;
if (self.lightLevel === 1) {
state.currentDescription = "The tube is now emitting light from one of its ends.";
} else {
state.currentDescription = "The tube goes dark.";
}
}
function flashlightGet(_self, state) {
// TODO: Don't let the player pick up if they can't see it
const itemId = "flashlight1";
if (state.player.itemIds.has(itemId)) {
state.currentDescription = "You are already holding the black tube.";
return;
}
for (const room of Object.values(state.rooms)) {
room.itemIds.delete(itemId);
}
state.player.itemIds.add(itemId);
state.currentDescription = "You pick up the tube.";
}
export const PERMANENT = {
items: {
leader: {
aliases: ["leader", "shaman", "papa"],
moveable: false,
passive: {
see: "the leader in the center, facing you and speaking to you",
hear: "the leader asking you a question",
},
location: "home",
sense: {
see: "The leader addresses you, asking a question, and gestures to the carved tablet they hold and the jar of paint on your belt.",
hear: `The leader asks you to go west to the place of honor, and bring back its power to your community.
The leader notes you have a jar of paint strapped to your belt and tells you to mark your knowledge so
others may learn of the place's honor and power.`,
taste: "You think it would be unwise to try to taste the leader.",
touch: "You embrace the leader. You know the risks they are asking of you.",
smell: "Your leader smells like sweat, stale from the long walk. Past the animal odor you can still make out rose blossoms.",
},
},
leader_tablet: {
aliases: ["tablet", "stone"],
moveable: false,
passive: {
see: "a stone tablet in the leader's hands",
},
writing: "a place of honor",
location: "home",
sense: {
see: "The tablet is chiseled with both ancient runes and a modern script.",
},
rosetta: "place honor",
},
monolith1: {
aliases: ["monolith", "stone", "gray stone monolith"],
moveable: false,
writing: WARNING_LINES.slice(0, 5).join("\n"),
sense: {
see: "A gray stone monolith, twice your height, with writing engraved into it. Some of the writing has been worn away.",
touch: "The monolith is cold and smooth.",
taste: "Stony and mineral-like.",
},
location: "outside",
passive: {
see: "a gray stone monolith",
},
rosetta: "",
write: "You carefully paint on the monolith to help your community understand the strange symbols found in this place.",
},
info_text_1: {
aliases: [
"first panel",
"panels",
"panel",
"writing",
"damaged panel",
"altered panel",
],
moveable: false,
location: "information center",
passive: {
see: "a stone panel with damaged or altered text",
},
sense: {
see:
"The panel has engraved writing similar to that on the gray monolith. " +
"On one of the lines, all of the words but three have been chisiled away. " +
"In the margin next to this line, three words have been shallowly scratched into the stone.",
},
rosetta: "not place honor",
writing: INFOCENTER_PANEL1.join("\n"),
},
illegible_panels: {
aliases: ["second panel", "third panel", "other panels", "panels"],
moveable: false,
location: "information center",
passive: {
see: "two more stone panels with text",
},
sense: {
see: "A stone panel with some sort of engraving on it. It might be writing, but you do not recognize the characters.",
},
},
berm1: {
aliases: ["berm", "slope", "earth", "grass"],
moveable: false,
sense: {
see: "To the west is a berm, a gradual slope of grass-covered earth that rises above your head then levels off. You could climb it. It extends thousands of strides to the north and south.",
hear: "The berm is covered in grass, which rustles softly in the gentle breeze.",
touch: "The ground is grass-covered, but not soft; it feels well-packed.",
smell: "The ground has a slight smell of grass and earth, but not of loam.",
taste: "The ground is dusty -- low in clay or loam.",
},
location: "outside",
passive: {
see: "a slope of earth rising above your head to the west",
},
},
infocenter_hotcell_hole: {
aliases: ["door", "hole"],
moveable: false,
location: "information center",
passive: {
see: "a person-sized hole in the ground near one wall",
touch: "a person-sized hole in the ground near one wall",
},
sense: {
see: "The hole extends down half your height, then parallel to the wall. You could crawl through it.",
touch: "The hole extends down the length of your leg, then parallel to the wall. You could crawl through it.",
},
},
hotcell_hole_marker: {
aliases: ["disc", "disk", "stone", "marker"],
moveable: true,
location: "hot cell tunnel",
/*
TODO: "Several alternative materials have been suggested for use as Small Subsurface
Markers including granite, quartz, aluminum, titanium, stainless steel, hastealloy,
inconel, ceramics, glass (lanthanumborate made by the Corning Glass
Company), and highly durable plastics (polyethylene).
...
it is likely that rock and metal can be eliminated from the candidate list due to cost"
*/
passive: {
see: "a disc with symbols engraved on it",
touch: "a hard and smooth disc, head-sized, loose on the ground",
},
sense: {
touch: "A head-sized disc with symbols engraved on it. It is hard, and smoother than stone. The engraving is finer, shallow and narrow, but clear. It is cold.",
see: "The disc has more ancient text on it, as well as some unfamiliar symbols, larger than the letters.",
hear: "The disc makes a clinking sound when tapped.",
},
writing: "danger -- poisonous radioactive waste here -- do not dig or drill",
},
hotcell_infocenter_hole: {
aliases: ["door", "hole"],
moveable: false,
location: "hot cell",
passive: {
see: "a person-sized hole in one wall",
touch: "a person-sized hole in one wall",
},
sense: {
see: "The hole is the size of a crawling person. It tracks a gentle upward slope.",
touch: "The hole is the size of a crawling person. It tracks a gentle upward slope.",
},
},
hotcell_switch: {
aliases: ["cylinder", "switch", "button"],
moveable: false,
location: "hot cell",
passive: {
see: "a raised cylinder, smaller than your finger, protruding from the wall near the hole",
touch: "a raised cylinder, smaller than your finger, protruding from the wall near the hole",
},
sense: {
see: "A raised cylinder, about the size of your last pinky joint. It is made of an unfamiliar, shiny material.",
touch: "A raised cylinder, about the size of your last pinky joint. It is made of an unfamiliar material, not quite metal: smooth, hard, and neither warm nor cold. It seems to shift slightly, vertically, as you touch it.",
taste: "A raised cylinder, about the size of your last pinky joint. It is made of an unfamiliar material, bitter-tasting.",
},
action: [
{
aliases: ["push", "flip", "activate", "toggle"],
callback: hotCellLightSwitch,
},
],
},
"hot cell light": {
aliases: ["light", "ceiling", "whine", "globe"],
moveable: false,
location: "nowhere",
passive: {
see: "a clear fist-sized globe, glowing yellow, out of reach, in center of the ceiling",
hear: "a faint whine coming from the center of the ceiling",
},
sense: {
see: "A clear fist-sized globe of an unfamiliar material. It gives off a yellow light, enough that you can make out the rest of the room clearly. It is attached to the center of the ceiling, well out of reach.",
hear: "A faint high-pitched whine eminates from the center of the ceiling, high above your head.",
},
lightLevel: 1,
},
flashlight1: {
aliases: ["tube", "torch", "stick", "flashlight"],
moveable: true,
location: "hot cell",
passive: {
see: "a strange tube on the ground near the hole",
touch: "a tube on the ground near the hole",
},
sense: {
see: "A black tube with a yellow dot near its base.",
taste: "It tastes of nothing, but in a way you have never before experienced.",
touch: "The tube fits comfortably in your hand. It is mostly hard, but one end seems softer.",
},
action: [
{
aliases: ["push", "flip", "activate", "toggle"],
callback: flashlightSwitch,
},
{
aliases: ["get", "grab", "hold"],
callback: flashlightGet,
},
],
},
},
rooms: {
nowhere: {
// Placeholder place for items that don't otherwise have a location.
rad_rate: Infinity,
exits: {},
senses: {
see: "You should't be here.",
hear: "You should't be here.",
smell: "You should't be here.",
touch: "You should't be here.",
taste: "You should't be here.",
},
droneVolume: 10,
},
outside: {
exits: {
west: "information center",
berm: "outside",
"information center": "information center",
},
// Rads per second
rad_rate: 0,
senses: {},
droneVolume: -13,
lightLevel: 1,
writeableItem: "monolith1",
},
"information center": {
exits: {
east: "outside",
outside: "outside",
hole: "hot cell tunnel",
down: "hot cell tunnel",
"through the hole": "hot cell tunnel",
"into the hole": "hot cell tunnel",
"into hole": "hot cell tunnel",
"into the hole": "hot cell tunnel",
},
rad_rate: 0.01,
senses: {
see: "four stone walls without a roof in a rectangle, with their tops at the edge of your reach",
touch: "four stone walls without a roof in a rectangle, with their tops at the edge of your reach",
},
droneVolume: -13,
lightLevel: 1,
},
"hot cell tunnel": {
exits: {
"towards the wind": "information center",
"towards the sound": "information center",
"to the sound": "information center",
"from the wind": "hot cell",
"away from the wind": "hot cell",
down: "hot cell",
up: "information center",
},
rad_rate: 0.05,
senses: {
see: "a long tunnel sloping gently downwards",
touch: "walls around you, the tunnel before and behind you, sloping gently downwards",
hear: "wind from the upper end of the tunnel",
smell: "earth",
},
droneVolume: -10,
},
"hot cell": {
exits: {
hole: "hot cell tunnel",
"through the hole": "hot cell tunnel",
"into the hole": "hot cell tunnel",
"into hole": "hot cell tunnel",
"into the hole": "hot cell tunnel",
out: "hot cell tunnel",
up: "hot cell tunnel",
tunnel: "hot cell tunnel",
},
rad_rate: 0.5,
senses: {
// TODO: Dark at first, have to find a light switch?
touch: "the air circulating through an open chamber",
smell: "something not quite earthen",
},
droneVolume: -10,
},
home: {
exits: {
west: "outside",
"to the place of honor": "outside",
},
rad_rate: 0,
senses: {
see: "your community looking at you",
hear: "the crowd's bated breath",
touch: "the heat from the crowd around you despite the cold air",
smell: "hundreds of bodies in close proximity",
taste: "your own sweat on your lips",
},
droneVolume: -Infinity,
lightLevel: 1,
},
},
};
export default PERMANENT;