forked from techreturners/lm-lab-intro-typescript-wonderland
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
46 lines (38 loc) · 1.23 KB
/
index.ts
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
import { enterTheRabbitHole } from './src/chapter_1/chapter_1_rabbit_hole';
import { clear, print, askQuestion } from './src/ui/console';
export function haveAdventures(): void {
clear(false);
print('--------------------------');
print('| Welcome to Wonderland! |');
print('--------------------------');
askQuestion(`What's your name? `, startAdventure); // 👉 FIXME ❌
}
function startAdventure(name: string): void {
if (name && name.length > 0) {
if (checkEntryCodeIsBiggerThanThree(numberBiggerThanThree)) {
return enterTheRabbitHole(name);
} else {
print('***************************************');
print(`Hi ${name}. Sadly, the entry code failed! ☹`);
return endAdventure();
}
} else {
print(`I don't know who you are!`);
return endAdventure();
}
}
function failImmediately() {
clear(false);
return endAdventure();
}
const numberBiggerThanThree: number = 11; // 👉 FIXME ❌
// 👉 FIXME ❌
function checkEntryCodeIsBiggerThanThree(code: number) {
return code > 3; // 👉 FIXME ❌
}
export function endAdventure(): void {
print('***************************************');
print('You did not make it through Wonderland. 😭');
askQuestion('Press ENTER to restart! ', haveAdventures);
}
haveAdventures();