Repository navigation
Expand file tree
/
Copy pathTextEscapeLockedEnglish.html
More file actions
469 lines (405 loc) · 11 KB
/
Copy pathTextEscapeLockedEnglish.html
File metadata and controls
469 lines (405 loc) · 11 KB
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TextEscape - The Locked School</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
background: #e5e7eb;
color: #0f172a;
}
.page {
min-height: 100vh;
padding: 18px;
display: flex;
justify-content: center;
align-items: flex-start;
}
.game {
width: 100%;
max-width: 1050px;
display: grid;
grid-template-columns: 1fr 320px;
gap: 16px;
}
.card {
background: white;
border: 2px solid #cbd5e1;
border-radius: 18px;
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
padding: 22px;
}
.title-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
.icon {
width: 42px;
height: 42px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 12px;
background: #f1f5f9;
border: 1px solid #cbd5e1;
font-size: 24px;
}
h1 {
margin: 0;
font-size: 30px;
}
h2 {
margin: 0 0 12px;
font-size: 21px;
}
p {
font-size: 18px;
line-height: 1.55;
margin: 0 0 18px;
}
.choices {
display: grid;
gap: 10px;
}
button {
border: 0;
border-radius: 14px;
padding: 15px 16px;
background: #0f172a;
color: white;
font-size: 16px;
text-align: left;
cursor: pointer;
}
button:hover {
background: #334155;
}
.side {
display: grid;
gap: 16px;
}
.item, .note, .test {
border-radius: 12px;
padding: 10px 12px;
margin-top: 8px;
font-size: 16px;
border: 1px solid #cbd5e1;
background: #f8fafc;
}
.note {
background: #ecfeff;
border-color: #67e8f9;
font-weight: 600;
}
.empty {
color: #475569;
font-size: 16px;
margin: 0;
}
.code-box {
background: #fffbeb;
border: 2px solid #fbbf24;
border-radius: 16px;
padding: 16px;
margin: 16px 0;
}
.code-row {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: center;
}
input {
width: 150px;
padding: 12px;
border-radius: 12px;
border: 2px solid #0f172a;
font-size: 28px;
letter-spacing: 12px;
font-weight: bold;
color: #0f172a;
background: white;
}
.small-button {
background: white;
color: #0f172a;
border: 2px solid #0f172a;
text-align: center;
padding: 10px 12px;
}
.small-button:hover {
background: #f1f5f9;
}
.error {
color: #b91c1c;
font-weight: bold;
margin-top: 10px;
}
.pass {
color: #15803d;
font-weight: bold;
}
.fail {
color: #b91c1c;
font-weight: bold;
}
@media (max-width: 850px) {
.game {
grid-template-columns: 1fr;
}
h1 {
font-size: 25px;
}
}
</style>
</head>
<body>
<div class="page">
<main class="game">
<section class="card">
<div class="title-row">
<span class="icon" id="sceneIcon">🔒</span>
<h1 id="sceneTitle">TextEscape</h1>
</div>
<p id="sceneText"></p>
<div id="codeBox"></div>
<div class="choices" id="choices"></div>
</section>
<aside class="side">
<section class="card">
<h2>🎒 Inventory</h2>
<div id="inventory"></div>
</section>
<section class="card">
<h2>🧩 Clues</h2>
<div id="notes"></div>
</section>
<section class="card">
<h2>Game</h2>
<p class="empty" id="moves">Moves: 0</p>
<button class="small-button" onclick="resetGame()">↻ Restart</button>
<button class="small-button" onclick="toggleTests()" style="margin-top:8px; width:100%;">Show tests</button>
<div id="tests" style="display:none;"></div>
</section>
</aside>
</main>
</div>
<script>
const GAME_CODE = "388";
let scene = "start";
let inventory = [];
let notes = [];
let moves = 0;
let testsVisible = false;
function has(item) {
return inventory.includes(item);
}
function addItem(item) {
if (!inventory.includes(item)) inventory.push(item);
}
function addNote(note) {
if (!notes.includes(note)) notes.push(note);
}
function solveCodeFromClues() {
const triangleCorners = 3;
const numbers = [8, 11, 4];
const largestEvenBook = Math.max(...numbers.filter(n => n % 2 === 0));
const spiderLegs = 8;
return String(triangleCorners) + String(largestEvenBook) + String(spiderLegs);
}
function runTests() {
return [
{ name: "Clue code matches escape code", passed: solveCodeFromClues() === GAME_CODE },
{ name: "Wrong code should not pass", passed: "381" !== GAME_CODE },
{ name: "Code must be 3 digits", passed: GAME_CODE.length === 3 && /^\d{3}$/.test(GAME_CODE) }
];
}
function getScenes() {
return {
start: {
title: "TextEscape: The Locked School",
icon: "🔒",
text: "You are stuck in school after closing time. The hallway is empty. Lights are flickering. The speakers crackle: 'System locked. Find the master code before midnight.'",
choices: [
["Go to Classroom 4B", "klassrum"],
["Go to the Library", "bibliotek"],
["Go to the Cafeteria", "matsal"],
["Inspect the Emergency Exit", "dod"]
]
},
klassrum: {
title: "Classroom 4B",
icon: "🔦",
text: "On the board it says: 'The first digit is the number of corners in a triangle.' Under the teacher's desk is a small flashlight.",
onEnter: function() {
addItem("flashlight");
addNote("First digit = triangle corners.");
},
choices: [
["Back to hallway", "start"],
["Check desks", "bankar"]
]
},
bankar: {
title: "Desks",
icon: "🗝️",
text: "Inside a desk you find a small silver key. It says: 'STAFF'. It seems important.",
onEnter: function() { addItem("silver_key"); },
choices: [["Back", "klassrum"]]
},
bibliotek: {
title: "Library",
icon: "📚",
text: has("flashlight")
? "With the flashlight you see something between the shelves. Three books stand out: 8, 11, and 4."
: "It is too dark to see anything. You need light.",
choices: has("flashlight")
? [["Pull book 8", "bok8"], ["Pull book 11", "wrongbook"], ["Pull book 4", "wrongbook"], ["Back", "start"]]
: [["Back", "start"]]
},
bok8: {
title: "Hidden Book",
icon: "🗝️",
text: "The book clicks. Inside is a note: 'The second digit is 8.'",
onEnter: function() { addNote("Second digit = 8."); },
choices: [["Back to hallway", "start"]]
},
wrongbook: {
title: "Wrong Book",
icon: "⚠️",
text: "A speaker says: 'Wrong choice.' Nothing bad happens, but you lost time.",
choices: [["Try again", "bibliotek"], ["Back", "start"]]
},
matsal: {
title: "Cafeteria",
icon: "🍽️",
text: "On a table are four plates. One is blue. It says: 'The last digit is the number of legs on a spider.'",
onEnter: function() { addNote("Last digit = spider legs."); },
choices: [["Back", "start"], ["Check behind counter", "disk"]]
},
disk: {
title: "Behind Counter",
icon: "🗝️",
text: has("silver_key")
? "The silver key opens a locker. Inside is an ID card."
: "A locked locker says 'STAFF'.",
onEnter: function() {
if (has("silver_key")) addItem("ID_card");
},
choices: [["Back", "matsal"]]
},
dod: {
title: "Emergency Exit",
icon: "🚪",
text: has("ID_card")
? "The scanner turns green. Now you need the 3-digit master code."
: "You need an ID card first.",
code: has("ID_card"),
choices: [["Back", "start"]]
},
victory: {
title: "You Escaped",
icon: "✅",
text: "The lock beeps. The door opens. You escape just before the lights go out.",
choices: [["Play again", "RESET"]]
}
};
}
function render() {
const scenes = getScenes();
const current = scenes[scene] || scenes.start;
if (current.onEnter) current.onEnter();
document.getElementById("sceneIcon").textContent = current.icon;
document.getElementById("sceneTitle").textContent = current.title;
document.getElementById("sceneText").textContent = current.text;
document.getElementById("moves").textContent = "Moves: " + moves;
renderChoices(current.choices);
renderCodeBox(current.code);
renderInventory();
renderNotes();
renderTests();
}
function renderChoices(choices) {
const el = document.getElementById("choices");
el.innerHTML = "";
choices.forEach(c => {
const b = document.createElement("button");
b.textContent = c[0];
b.onclick = () => {
if (c[1] === "RESET") resetGame();
else {
moves++;
scene = c[1];
render();
}
};
el.appendChild(b);
});
}
function renderCodeBox(show) {
const box = document.getElementById("codeBox");
box.innerHTML = "";
if (!show) return;
box.innerHTML = `
<div class="code-box">
<strong>Enter master code:</strong>
<div class="code-row">
<input id="codeInput" maxlength="3" inputmode="numeric" placeholder="___" />
<button onclick="submitCode()">Unlock</button>
</div>
<div id="codeMessage" class="error"></div>
</div>
`;
}
function submitCode() {
const input = document.getElementById("codeInput");
const msg = document.getElementById("codeMessage");
const val = input.value.replace(/\D/g, "").slice(0, 3);
if (val === GAME_CODE) {
scene = "victory";
moves++;
render();
} else {
msg.textContent = "Wrong code. Check clues again.";
}
}
function renderInventory() {
const el = document.getElementById("inventory");
el.innerHTML = inventory.length ? inventory.map(i => `<div class="item">${i}</div>`).join("") : "<p class='empty'>Nothing yet.</p>";
}
function renderNotes() {
const el = document.getElementById("notes");
el.innerHTML = notes.length ? notes.map(n => `<div class="note">${n}</div>`).join("") : "<p class='empty'>No clues yet.</p>";
}
function toggleTests() {
testsVisible = !testsVisible;
renderTests();
}
function renderTests() {
const el = document.getElementById("tests");
el.style.display = testsVisible ? "block" : "none";
if (!testsVisible) return;
el.innerHTML = runTests().map(t =>
`<div class="test"><span class="${t.passed ? "pass" : "fail"}">${t.passed ? "PASS" : "FAIL"}</span> ${t.name}</div>`
).join("");
}
function resetGame() {
scene = "start";
inventory = [];
notes = [];
moves = 0;
testsVisible = false;
render();
}
render();
</script>
</body>
</html>