-
Notifications
You must be signed in to change notification settings - Fork 0
/
chair.js
441 lines (356 loc) · 9.11 KB
/
chair.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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// Author: Alex Leone
// 10 Jan 2022
// Converted to JavaScript from Python from a TI-84 program
(function () {
var chairKicks = 1;
var doorHits = 1;
var freeFromSpell = false;
var wordsGained = 0;
function scene1() {
game.log("There is a chair in the middle of the room. It is holding all your attention. (Press Enter)");
goToSceneAfterEnter(2);
}
function scene2() {
game.log("What do you do?");
goToSceneAfterEnter(3);
}
function scene3() {
var menu = `1-Look away from the chair
2-Look through the chair
3-Kick the chair
4-`;
if (wordsGained >= 1 && !freeFromSpell) {
menu += "Speak to the chair";
} else {
menu += "Sit in chair"
}
game.log(menu);
game.read(function (choice) {
if (choice === "1") {
if (freeFromSpell) {
goToScene(9);
} else {
goToScene(4);
}
} else if (choice === "2") {
goToScene(5);
} else if (choice === "3") {
if (chairKicks >= 3) {
goToScene(7);
} else {
goToScene(6);
}
} else if (choice === "4") {
if (freeFromSpell) {
goToScene(23);
} else {
goToScene(8);
}
} else {
goToScene(3);
}
});
}
function scene4() {
game.log("You can't. The chair is holding all of your attention.");
goToSceneAfterEnter(3);
}
function scene5() {
game.log("You don't have X-ray vision.");
game.read(function () {
game.log("What do you really do?");
goToSceneAfterEnter(3);
});
}
function scene6() {
if (!freeFromSpell) {
game.log("The chair does not move. It shakes.");
chairKicks += 1;
} else {
game.log("The chair moves.");
}
goToSceneAfterEnter(2);
}
function scene7() {
game.log("The chair moves across the floor. You are free from its spell.");
goToSceneAfterEnter(9);
}
function scene8() {
if (wordsGained >= 2) {
goToScene(22);
} else if (wordsGained >= 1) {
game.log("You cannot speak. The chair is holding all of your attention.");
goToSceneAfterEnter(3);
} else {
game.log("You cannot move.");
goToSceneAfterEnter(3);
}
}
function scene9() {
game.log("There is, in the room: a door, a chair, and a hole. What do you do?");
chairKicks = 1;
freeFromSpell = false;
goToSceneAfterEnter(10);
}
function scene10() {
game.log(
`1-Look at the door
2-Look at the chair
3-Look at the hole`
);
game.read(function (choice) {
if (choice === "1") {
goToScene(12);
} else if (choice === "2") {
goToScene(11);
} else if (choice === "3") {
goToScene(17);
} else {
goToScene(10);
}
});
}
function scene11() {
game.log("The chair is holding all of your attention.");
goToSceneAfterEnter(2);
}
function scene12() {
game.log("The door is wood and really big. It scares you.");
goToSceneAfterEnter(13);
}
function scene13() {
game.log("What do you do?");
goToSceneAfterEnter(14);
}
function scene14() {
game.log(
`1-Hit the door
2-Look away from the door
3-Scare the door`);
game.read(function (choice) {
if (choice === "1") {
if (doorHits >= 5) {
if (doorHits === 5) {
goToScene(27);
} else {
goToScene(28);
}
} else {
goToScene(15);
}
} else if (choice === "2") {
goToScene(9);
} else if (choice === "3") {
goToScene(16);
} else {
goToScene(14);
}
});
}
function scene15() {
game.log("You hit your hand on the door. Your hand hurts.");
doorHits += 1;
goToSceneAfterEnter(13);
}
function scene27() {
game.log("You break your hand on the hard wood door.");
doorHits += 1;
goToSceneAfterEnter(13);
}
function scene28() {
game.log("You can't move your hand. It's broken.");
goToSceneAfterEnter(13);
}
function scene16() {
if (wordsGained < 1) {
game.log("You say BOO. The door is unaffected by your tactics.");
goToSceneAfterEnter(13);
} else {
game.log("What do you say to the door? (Type your answer.)");
game.read(function(answer) {
if (answer !== "OOB") {
game.log("No good.");
goToSceneAfterEnter(13);
} else {
game.log("The door trembles, and for a brief moment, a single word appears engraved on the door:");
game.read(function () {
game.log("EERF");
if (wordsGained < 2) {
wordsGained = 2;
}
goToSceneAfterEnter(13);
});
}
});
}
}
function scene17() {
game.log("The hole is black. You cannot see the back of it.");
goToSceneAfterEnter(18);
}
function scene18() {
game.log(
`1-Blow into the hole
2-Scare the hole
3-Look into hole
4-Look away from the hole`);
game.read(function(choice) {
if (choice === "1") {
goToScene(19);
} else if (choice === "2") {
goToScene(20);
} else if (choice === "3") {
goToScene(21);
} else if (choice === "4") {
goToScene(9);
} else {
goToScene(18);
}
});
}
function scene19() {
game.log("Your breath comes back at you. Phew. Take a mint.");
goToSceneAfterEnter(18);
}
function scene20() {
game.log("You say BOO. Out of the inky blackness, you hear a single word emerge...");
game.read(function () {
game.log("OOB.");
if (wordsGained < 1) {
wordsGained = 1;
}
goToSceneAfterEnter(18);
});
}
function scene21() {
game.log("It is very dark in there.");
goToSceneAfterEnter(18);
}
function scene22() {
game.log("You can speak. What do you want to say to the chair? (Type your answer.)");
game.read(function (answer) {
if (answer !== "EERF") {
game.log("No good.");
goToSceneAfterEnter(2);
} else {
game.log("You are free from the spell.");
freeFromSpell = true;
goToSceneAfterEnter(2);
}
});
}
function scene30() {
game.log("The ceiling falls in on you and you are transported to another realm.");
game.read(function () {
game.log("TO BE CONTINUED...");
game.read(function () {
return;
});
});
}
function scene23() {
game.log("You are sitting in the chair, feeling either like a king or a jack-o-lantern.");
chairKicks = 1;
goToSceneAfterEnter(24);
}
function scene24() {
game.log("What to do here?");
game.log(
`1-Get up
2-Look up
3-Talk to yourself`);
game.read(function (choice) {
if (choice === "1") {
goToScene(2);
} else if (choice === "2") {
goToScene(26);
} else if (choice === "3") {
goToScene(25);
} else {
goToScene(24);
}
});
}
function scene25() {
if (wordsGained < 3) {
game.log("You are crazy...");
goToSceneAfterEnter(24);
} else {
game.log("What do you want to say? (Type your answer.)");
game.read(function (answer) {
if (answer !== "UP") {
game.log("You are crazy...");
goToSceneAfterEnter(24);
} else {
goToScene(30);
}
});
}
}
function scene26() {
game.log("You see a single word written on the ceiling:");
game.read(function () {
game.log("PU");
if (wordsGained < 3) {
wordsGained = 3;
}
goToSceneAfterEnter(24);
});
}
function getSceneById(sceneName) {
var scenes = {
1: scene1,
2: scene2,
3: scene3,
4: scene4,
5: scene5,
6: scene6,
7: scene7,
8: scene8,
9: scene9,
10: scene10,
11: scene11,
12: scene12,
13: scene13,
14: scene14,
15: scene15,
27: scene27,
28: scene28,
16: scene16,
17: scene17,
18: scene18,
19: scene19,
20: scene20,
21: scene21,
22: scene22,
30: scene30,
23: scene23,
24: scene24,
25: scene25,
26: scene26,
};
var scene = scenes[sceneName]
return scene;
}
var nextScene = 1;
var game = html5console.init("game", {
allowEmptyInput: true,
defaultInputHandler: function () {
goToScene(nextScene);
}
});
game.log("~~~ CHAIR ~~~<br>a game by Alex Leone<br>~~~~~~~~~~~~~");
function goToSceneAfterEnter(sceneId) {
game.read(function () {
goToScene(sceneId);
});
}
function goToScene(sceneId) {
var scene = getSceneById(sceneId);
var result = scene();
if (typeof(result) === "number") {
nextScene = result;
}
}
goToScene(nextScene);
}());