forked from wdi-sg/unit1-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
406 lines (375 loc) · 15.1 KB
/
Copy pathscript.js
File metadata and controls
406 lines (375 loc) · 15.1 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
console.log("hello script js");
/*data types, variables, operators, conditional blocks,
and accepting user input, create a text-based game
that allows the user to arrive at
different "destinations" based on
the inputs they type.
*/
//Ask 3 ques for each path
//7 total desti based on their response
//each ques should have 2 possible responses
let state = 0;
let prompter = document.querySelector("#prompter")
let boxInput = document.querySelector("#input");
let isAboveBud = false;
let isAir = false;
let isLand = false;
let isOceania = false;
let isAsia =false;
let isSEA = false;
let isAus = false;
let isNZ = false;
let isSyd = false;
let isMelb = false;
let isAuck = false;
let isCCH = false;
let isCHN = false;
let isKOR = false;
let isMsia = false;
let isThai = false;
let isBei = false;
let isSHG = false;
let isSEO = false;
let isBUS = false;
let isKL = false;
let isPNG = false;
let isBKK = false;
let isPKT = false;
let name;
// const BTFInit = (currentInput) => {
// if( state === 0) {
// prompter.innerText = `Nice to meet you ${currentInput}. What year would you like to go to? (YYYY)`
// // boxInput.value = "";
// state++;
// } else if(state === 1){
// let numCurrentInput = parseInt(currentInput);
// if(numCurrentInput >= 2015){
// prompter.innerText = `I see you're a fan of Back to the Future 2. Would you rather deal with Biff, or Griff? (B/G)`
// }
// else if(numCurrentInput >= 1985 && numCurrentInput <= 2014){
// prompter.innerText =`Doc has already destroyed the Time Machine at this point. I guess you'll have to wait around until 2015. What name would you like to go by until then?`
// }
// else if(numCurrentInput>=1955 && numCurrentInput <= 2014){
// prompter.innerText =`I see you're a fan of Back to the Future 1. Your future Mom has just asked you to the Enchantment Under the Sea dance. What do you do? (Y/N/S)`
// }
// else if(numCurrentInput< 1955){
// prompter.innerText =`I see you're a fan of Back to the Future 3. You've run out of gas and can't get back to your own time! How do you power the Time Machine? (H/M/T)`
// } else {
// prompter.innerText = "YYYY out of range"
// }
// state++;
// } else if(state === 2) {
// if(currentInput === "B") {
// prompter.innerText = `Hmm, interesting. Biff is angry and has a cane. Do you stand and fight, or run away like a coward? (S/R)
// Stand and fight`
// } else if(currentInput === "G") {
// prompter.innerText = `Griff is asking you if you are in, or out. What do you say? (I/O)`
// } else if(currentInput === "Y") {
// prompter.innerText =`Creepy. I hope you have some backup plan in place to get out of this. Until then, you're stuck in 1955.`
// } else if(currentInput === "N") {
// prompter.innerText =`Honorable. But this also means that your future Dad will never meet your Mom, and therefore you cannot exist.`
// } else if(currentInput === "S") {
// prompter.innerText = `Interesting. You set up an elaborate plan for your future Dad to surprise your Mom by beating you up. Despite going horribly awry, the plan ultimately works. You may go back to your own time.`
// } else if(currentInput === "H") {
// prompter.innerText = `Good idea, but no. The time machine needs to get to 88mph. 12 horsepower ain't gonna cut it.`
// } else if(currentInput === "M") {
// prompter.innerText = `You'd be better off drinking the moonshine. Do not pass Go, do not collect $200. Stuck in 1855.`
// } else if(currentInput === "T") {
// prompter.innerText = `Good call! This plan seems to be working. But wait! Clara wants to go Back to the Future with you at the last moment. What do you do? (T/L)`
// } else {
// prompter.innerText = `Welcome to the future, ${currentInput}`
// }
// state++;
// } else if (state === 3){
// if (currentInput === "S"){
// prompter.innerText = `Good choice. Biff is old and feeble at this point. You push him over and he falls in a pile of manure.`
// } else if(currentInput === "R") {
// prompter.innerText = `You get away, but your future son Marty Jr. is heckled for the rest of his days for his dad's cowardice.`
// } else if(currentInput === "I") {
// prompter.innerText = `Bad call. Griff and his cronies rob the Hill Valley bank and frame you for it. No more time travel for you.`
// } else if(currentInput === "O") {
// prompter.innerText = `Good call. You deck Griff in the jaw and run away. He gives chase on his hoverboard and ends up in a pile of manure.`
// } else if(currentInput === "T") {
// prompter.innerText = `Interesting choice. Unfortunately the Doc can't grab Clara and get back to the car in time. He ends up staying in 1855 with her.`
// } else if(currentInput === "L") {
// prompter.innerText = `Smart choice. Unfortunately the Doc was deeply in love with Clara, and when he gets back to 1985 he becomes very depressed.`
// } else {
// prompter.innerText = "no options found"
// }
// state++;
// } else {
// prompter.innerText = "End of Game"
// }
// }
var inputHappened = function(currentInput){
console.log( currentInput );
travelInit(currentInput);
boxInput.value = "";
var output = "WOW SOMETHING HAPPENED";
return output;
};
// const oceania = {
// aus: {
// SYD: "sydney",
// MEL: "melbourne",
// },
// nz: {
// AUC: "auckland",
// CCH: "christchurch"
// }
// }
// const asia = {
// china:{
// BEI: "beijing",
// SHG: "shanghai"
// },
// korea:{
// SEO: "seoul",
// BUS: "busan"
// }
// }
// const sea = {
// msia:{
// KUL: "kl",
// PNG: "penang"
// },
// thai:{
// BKK: "bangkok",
// PKT: "phuket"
// }
// }
const travelInit = (currentInput) =>{
if( state === 0) {
name = currentInput;
prompter.innerText = `Welcome ${name}. Do you want to travel? (Y/N)`
state++;
} else if(state === 1){
if(currentInput === "Y"){
prompter.innerText = `You have selected Yes. Please advise your budget. Amount:`
state++
} else {
prompter.innerText = `Maybe next time!`
state = 0;
}
}else if(state === 2){
let numCurrentInput = parseInt(currentInput);
if(numCurrentInput >= 5000){
isAboveBud=true;
prompter.innerText = `Do you want to travel by Air or Land? (Air / Land) >>ST2`
state++;
} else if(numCurrentInput <= 5000){
prompter.innerText =`Do you want to travel by Air or Land? (Air / Land) >>ST2`
state++;
} else {
prompter.innerText = `Kindly provide a number`
state=2;
}
} else if(state === 3) {
if(currentInput === "Air" && isAboveBud) {
isAir=true;
prompter.innerText = `Which region do you prefer? --> (O)ceania, (A)sia, (S)EA >>ST3.A`
state++
} else if(currentInput === "Land" && isAboveBud) {
isLand=true;
prompter.innerText = `Which region do you prefer? --> (A)sia, (S)EA >>ST3.L`
state++
} else if((currentInput === "Land" || currentInput==="Air") && isAboveBud === false){
prompter.innerText = `Is SEA fine for you?(Y/N) >>ST3.REGARDLESS BELOW BUDGET`
state++
} else {
prompter.innerText = `Kindly select Air or Land >>ST3`
state=3;
}
} else if (state === 4){
if (currentInput === "O" && isAir && isAboveBud){
isOceania=true;
prompter.innerText = `Which country do you prefer? (AUS/NZ) >>ST4`
state++
} else if(currentInput === "A" && isAboveBud) {
isAsia = true;
prompter.innerText = `Which country do you prefer? (CHINA/KOREA) >>ST4`
state++
} else if(currentInput === "S" || currentInput === "Y") {
isSEA=true;
prompter.innerText = `Which country do you prefer? (MSIA/THAI) >>ST4`
state++
} else {
if(isAboveBud === false){
prompter.innerText = `Kindly update Budget (Above or Below 5K)`
state=2;
} else if(isAir === false) {
prompter.innerText = `Which region do you prefer? --> (A)sia, (S)EA >>ST4.L`
state=4;
}
}
} else if (state === 5){
if (currentInput === "AUS" && isOceania){
isAus=true;
prompter.innerText = `Which state do you prefer? (SYD/MELB) >>ST5`
state++
} else if(currentInput === "NZ" && isOceania) {
isNZ=true;
prompter.innerText = `Which state do you prefer? (AUCK/CCH) >>ST5`
state++
} else if(currentInput === "CHINA" && isAsia) {
isCHN=true;
prompter.innerText = `Which state do you prefer? (BEI/SHG) >>ST5`
state++
} else if(currentInput === "KOREA" && isAsia) {
isKOR=true;
prompter.innerText = `Which state do you prefer? (SEO/BUS) >>ST5`
state++
} else if(currentInput === "MSIA" && isSEA) {
isMsia=true;
prompter.innerText = `Which state do you prefer? (KL/PNG) >>ST5`
state++
} else if(currentInput === "THAI" && isSEA) {
isThai=true;
prompter.innerText = `Which state do you prefer? (BKK/PKT) >>ST5`
state++
} else {
prompter.innerText = `Kindly select a country in that region >>ST5`
state=5;
}
} else if (state === 6){
if (currentInput === "SYD" || currentInput === "MELB" || currentInput === "AUCK" || currentInput === "CCH" || currentInput === "BEI" || currentInput === "SHG" || currentInput === "SEO" || currentInput === "BUS" || currentInput === "KL" ||currentInput === "PNG"||currentInput === "BKK"||currentInput === "PKT"){
prompter.innerText = `Do you prefer Hotel or AirBNB? (H/A)`
state++
} else {
prompter.innerText = `Kindly select a state`
state=5;
}
} else if ( state=== 7){
if(currentInput === "H" || currentInput === "A"){
if(isAus){
if(isSyd) {
prompter.innerText = `Thanks! Checking ${currentInput} in Sydney `
state++
} else if(isMelb) {
prompter.innerText = `Thanks! Checking ${currentInput} in Melbourne `
state++
}
} else if(isNZ) {
if(isAuck) {
prompter.innerText = `Thanks! Checking ${currentInput} in Auckland `
state++
} else if(isCCH) {
prompter.innerText = `Thanks! Checking ${currentInput} in Christchurch `
state++
}
} else if(isCHN) {
if(isBei) {
prompter.innerText = `Thanks! Checking ${currentInput} in Beijing`
state++
} else if(isSHG) {
prompter.innerText = `Thanks! Checking ${currentInput} in Shanghai `
state++
}
} else if(isKOR) {
if(isSEO) {
prompter.innerText = `Thanks! Checking ${currentInput} in Seoul`
state++
} else if(isBUS) {
prompter.innerText = `Thanks! Checking ${currentInput} in Busan`
state++
}
} else if(isMsia) {
if(isKL) {
prompter.innerText = `Thanks! Checking ${currentInput} in KL`
state++
} else if(isPNG) {
prompter.innerText = `Thanks! Checking ${currentInput} in PNG `
state++
}
} else if(isThai) {
if(isBKK) {
prompter.innerText = `Thanks! Checking ${currentInput} in Bangkok`
state++
} else if(isPKT) {
prompter.innerText = `Thanks! Checking ${currentInput} in Phuket `
state++
}
}
} else {
prompter.innerText = `Sorry, there's only Hotel & Airbnb options. (H/A)`
state=7;
}
} else if(state=== 8) {
prompter.innerText = `Here are the results, ${name}`
}
}
//TRAVEL OR NO?
//--CHECK BUDGET
//MORE THAN 5000
//--TRAVEL BY AIR OR LAND
//AIR
//OCEANIA
//AUS
//SYD
//HOTEL
//AIRBNB
//MELB
//NZ
//AUCKLAND
//CHRISTCHURCH
//ASIA
//CHINA
//BJ
//SH
//KOREA
//SEOUL
//BUSAN
//SEA
//MSIA
//KL
//PENANG
//THAI
//BKK
//PHUKET
//LAND
//ASIA
//CHINA
//BJ
//SH
//KOREA
//SEOUL
//BUSAN
//SEA
//MSIA
//KL
//PENANG
//THAI
//BKK
//PHUKET
//LESS THAN 5000
//TRAVEL BY AIR OR LAND
//AIR
//ASIA
//CHINA
//BJ
//SH
//KOREA
//SEOUL
//BUSAN
//SEA
//MSIA
//KL
//PENANG
//THAI
//BKK
//PHUKET
//LAND
//ASIA
//CHINA
//BJ
//SH
//KOREA
//SEOUL
//BUSAN
//SEA
//MSIA
//KL
//PENANG
//THAI
//BKK
//PHUKET