-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.js
384 lines (374 loc) · 12.6 KB
/
game.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
const textElement = document.getElementById('text')
const optionButtonsElement = document.getElementById('option-buttons')
const timeElement = document.getElementById('time')
let state = {}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function startTime() {
const today = new Date();
const hours = today.getHours();
const minutes = today.getMinutes();
h = checkTime(hours);
m = checkTime(minutes);
timeElement.innerHTML = h + ":" + m;
}
startTime();
function startGame() {
state = {}
showTextNode(1)
}
function showTextNode(textNodeIndex) {
const textNode = textNodes.find(textNode => textNode.id === textNodeIndex)
textElement.innerText = textNode.text
while (optionButtonsElement.firstChild) {
optionButtonsElement.removeChild(optionButtonsElement.firstChild)
}
textNode.options.forEach(option => {
if (showOption(option)) {
button = document.createElement('button')
button.innerText = option.text
button.classList.add('btn')
button.addEventListener('click', () => selectOption(option))
optionButtonsElement.appendChild(button)
}
})
}
function showOption(option) {
return option.requiredState == null || option.requiredState(state)
}
function selectOption(option) {
const nextTextNodeId = option.nextText
if (nextTextNodeId <= 0) {
return startGame()
}
state = Object.assign(state, option.setState)
showTextNode(nextTextNodeId)
}
const textNodes = [
{
id: 1,
text: 'Today is a great day! It is the start of your journey to the Castle of wonders! As a young knight developer, you will need courage, determination, and support to obtain your first role as a knight, in the Castle of wonders. But first, you need to prepare before your adventure.',
options: [
{
text: 'Go to a Tech Event',
setState: { feedback: false },
nextText: 2,
},
{
text: 'Apply for a job',
setState: { mentor: false },
nextText: 6,
}
]
},
{
id: 2,
text: 'You arrive at the event. There is a crowd, but enough space to grab a Club Matte and talk with attendees before the talks start. During the evening, you listen to fascinating quests from your fellow dev knights: Microservices to rescue endangered kingdoms, lightening talks about designing magic potions for wizard... So many interesting topics! At one point, the talks come to an end.',
options: [
{
text: 'Speak to the event organizer',
setState: { mentor: true },
nextText: 4
},
{
text: 'Thank the public speaker for her presentation',
setState: { mentor: true },
nextText: 5
},
{
text: 'Eat all the pizza',
setState: { mentor: false },
nextText: 3
},
]
},
{
id: 3,
text: 'That was yummy! I feel a bit tired now, time to go to bed!',
options: [
{
text: 'Go to bed',
nextText: 11
}
]
},
{
id: 4,
text: 'The wizard organizer is highly pleased and you start to discuss and get to know each other. You discover that you both use the same tools to craft products! The wizard decides to help you in your quest and become a mentor!',
options: [
{
text: 'Go to bed',
nextText: 11
}
]
},
{
id: 5,
text: 'The public speaker is pleased with your feedback! You start having a discuss and get to know each other. You discover that you both have the same interest in finding a role at the Castle of wonders! You have a new ally and the speaker decides to help you in your quest!',
options: [
{
text: 'Go to bed',
nextText: 11
}
]
},
{
id: 6,
text: "You go online and apply for several jobs that seem to fit to your dev knight skills. You go to bed full of hopes and the day after you receive a positive reply from a company! You book an appointment for the first interview! Lets go! During the interview, you meet the Tech recruiter, few knight developers and go through discussions about your passed quests and achievements. At the end of the day, you reflect about your first interview: It went well!! You wait few days, and receive a carrier pigeon informing you that unfortunately they won't proceed further with your holy application. The recruiter suggests to have a call in order to give you a feedback.",
options: [
{
text: 'Yes, please!',
setState: { feedback: true },
nextText: 8
},
{
text: 'No, thank you',
nextText: 7
}
]
},
{
id: 7,
text: 'You are feeling sad and want to do something to change your mind',
options: [
{
text: 'Go to a tech event',
nextText: 10
},
{
text: 'Go to bed',
nextText: 9
}
]
},
{
id: 8,
text: 'After listening to the recruiter, you realized that you have room for improvements regarding the code challenge you made. Even though the answer was negative, it gives you more confidence for your quest, and a good learning.',
options: [
{
text: 'Go to a tech event',
nextText: 10
},
{
text: 'Go to bed',
nextText: 9
}
]
},
{
id: 9,
text: 'Tomorrow is another day. You go to bed and have a restful sleep.',
options: [
{
text: 'Sleep',
nextText: 11
}
]
},
{
id: 10,
text: "You go to a tech event, but unfortunately you feel down and not focused on the presentations, nor want to discuss with other fellow knights. You eat a lot of pizza, it helps a bit. Time to go to bed! Maybe tomorrow will be a better day!",
options: [
{
text: 'Sleep',
nextText: 11
}
]
},
{
id: 11,
text: 'New day, new you!!! What do you feel about doing?',
options: [
{
text: 'Go to Linkedin',
nextText: 12
},
{
text: 'Work on my portfolio',
requiredState: (currentState) => currentState.mentor,
nextText: 13
},
{
text: 'Work on code challenges',
requiredState: (currentState) => currentState.feedback,
nextText: 14
}
]
},
{
id: 12,
text: 'You come across different jobs to apply to. Suddendly, a wild head hunter appears! His message: We have an amazing opportunity for you! Here are the skills the company is looking for:Java, Python, PHP, React, Angular, postgresql, Redis, MongoDB AWS, S3, EC2, ECS,EKS, nix systm administration,Git, CI with TDD, Docker, Kubernetes',
options: [
{
text: 'Wow! I am interested',
nextText: 15
},
{
text: 'That is not a Full Stack Developer, thats an entire IT department!',
nextText: 16
}
]
},
{
id: 13,
text: 'You work on your portfolio and projects you worked on during your studies. But a wild ennemy appears! Its a bug!',
options: [
{
text: 'Take care of it!',
setState: { bugSolved: true, mentor: false },
nextText: 17
},
{
text: 'Meh, it is fine. Nobody will see it anyway.',
setState: { mentor: true, bugSolved: false },
nextText: 22
},
{
text: 'It is not a bug, it is a feature',
setState: { mentor: true, bugSolved: false },
nextText: 22
}
]
},
{
id: 14,
text: 'You continue training through online coding challenge to get used to it and better at it. You realise your main weakness is that you do spaghetti code!',
options: [
{
text: 'Fight!',
setState: { spaghettiSolved: true, feedback: false },
nextText: 20
},
{
text: 'Why is that a problem?',
setState: { feedback: true, spaghettiSolved: false },
nextText: 22
}
]
},
{
id: 15,
text: 'You end up going to an interview that was really bad, recruiter did not have a clue about tech you have, job position was extrremely broad. End up decline application. GAME OVER',
options: [
{
text: 'Restart!',
nextText: -1
}
]
},
{
id: 16,
text: 'After declining this weird offer, you continue you adventure on LinkedIn and other platforms.',
options: [
{
text: 'The next day',
nextText: 22
}
]
},
{
id: 17,
text: 'You start working on this issue, console log, debugging, talking to your rubber duck, hoping it will help you to solve this. After a trip to Stackoverflow and more documentation, you finally see the error! The famous missing semicolon!',
options: [
{
text: 'Hurray!',
nextText: 22
}
]
},
{
id: 20,
text: 'No time to waste! You start your journey to improve on coding challenges. Hackerrank, Code Wars, coderbyte, nothing can stop you! You are getting so good at it, you became a celebrity on the coding platform!',
options: [
{
text: 'Much wow!',
nextText: 22
}
]
},
{
id: 22,
text: 'After a long day of preparation, and a good night of sleep, you are fully ready for a new day of researches. You apply to different roles that match your knight skills. After few days, you receive a positive answer for THE dev role you dreamt about! You have a serie of interviews at the Castle of Wonders. During the first interview, you meet the manager and leader of the Dev Knight Fellowship. You are impressed, but you also want to show your worth!',
options: [
{
text: 'Discuss about the weather',
nextText: 23
},
{
text: 'Show your projects',
requiredState: (currentState) => currentState.mentor,
nextText: 24
},
{
text: 'Show your technical skills',
requiredState: (currentState) => currentState.feedback,
nextText: 25
},
{
text: 'Take the code challenge first',
requiredState: (currentState) => currentState.spaghettiSolved,
nextText: 27
},
{
text: 'Show your portfolio',
requiredState: (currentState) => currentState.bugSolved,
nextText: 26
}
]
},
{
id: 23,
text: 'Unfortunately, you did not make a good impression. You end up stressed and unprepared for the other steps of the interview. After few days, the recruiter politely declined your application by carrier pigeon. GAME OVER',
options: [
{
text: 'Restart!',
nextText: -1
}
]
},
{
id: 24,
text: "You share your portfolio, and the recruiter takes some time to react to what he sees. After a minute, he says:'Is it supposed to be blank?' You look at his screen and see a white page. The portfolio has several errors that did not get fixed! You give him an embarassed smile. He does not smile back at you.GAME OVER",
options: [
{
text: 'Restart!',
nextText: -1
}
]
},
{
id: 25,
text: "I'll show you my worth by doing the code challenge first! The recruiter looks surprised, but gladly accepts to go through this step. He sends you the assignment and sits next to you. 'Are you staying here until I'm done?' 'Of course!' He says, 'We're going to do pair programming!' Oh no, you're were not prepared to this! You start to panic and it feel that your brain is suddenly not working anymore. After a while, you come to the conclusion that you won't be able make it through the last interview. GAME OVER",
options: [
{
text: 'Restart!',
nextText: -1
}
]
},
{
id: 26,
text: "You share your portfolio, and the recruiter looks pleasantly surprised. 'Who knew you could craft projects like these. It's pure genius!' You feel relieved and proud of your hard work. The discussion continues about your fighting skills, your team spirit and work with fellow wizards and mages. Once the interview is over, you hear the recruiter talking to his colleague: 'I think we've found our next fellow'. CONGRATULATIONS!!",
options: [
{
text: 'Restart!',
nextText: -1
}
]
},
{
id: 27,
text: "Right before he finishes his sentence, you tell him with conviction: 'Give me anything, I'm ready to fight!' The recruiter looks pleasantly surprised. 'Perfect then, let's do it!' He sends you the task and sits next to you. The instructions remind you of a challenge you did a couple days ago. It's going to be a piece of cake! You process carefully and clearly through the issues, explain each step you are working on. You even finish on time! Once the interview is over, you hear the recruiter talking to his colleague: 'I think we've found our next fellow'. CONGRATULATIONS!!",
options: [
{
text: 'Restart!',
nextText: -1
}
]
}
]
startGame()