-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
331 lines (228 loc) · 8.11 KB
/
Copy pathindex.js
File metadata and controls
331 lines (228 loc) · 8.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
#!/usr/bin/env node
//it will color the output text in the terminal
import chalk from "chalk";
// add rainbow animation in that text
import chalkAnimation from "chalk-animation";
// to implement ascii art from text
import figlet from "figlet";
// it has capacity to take input from terminal
import inquirer from "inquirer";
import inspector from "inspector";
// for a spinning effect in terminal and also for checking answers
import {createSpinner} from "nanospinner";
// for coloring the terminal
import gradientString from "gradient-string";
import { type } from "os";
import gradient from "gradient-string";
import { promises } from "dns";
//for test
// console.log(chalk.bgYellow("heyyy dear"));
// console.log(chalkAnimation.rainbow("heyyy dear"));
let player;
let Gender;
// javascript does'nt allow us to implement a promise based timeout so this line of code will help
const sleep = (ms = 2000) => new Promise((r) => setTimeout(r , ms));
async function welcome() {
console.clear();
const tittle = chalkAnimation.rainbow(
'who wants to be my friend ? \n'
);
await sleep();
tittle.stop();
console.log(`
${chalk.bgBlue(' how to play ')}
look, i am not a computer
i am a human being name ${chalk.yellow(' surajj')}
so if you wants to be my friend must answer the right answers.
`);
}
async function playername() {
const answers = await inquirer.prompt({
// variable name
name: 'player_name',
// specify the type
type: 'input',
// from what prompt you want to take the input from user
message: 'what is your name',
// it will give the default value as player
default(){
return 'Player'
}
})
// assining the global variable player to the input of the user
player = answers.player_name;
}
async function askGender() {
const answers = await inquirer.prompt ({
name: 'gender',
type: 'list',
message: chalk.yellow('your gender \n'),
choices: [
'Male',
'Female'
],
default(){
return 'Men'
}
});
if(answers.gender==='Male')Gender="Mr.";
else Gender="Miss."
}
// define your question
async function question1() {
console.clear();
const answers = await inquirer.prompt ({
name: 'question1',
type: 'list',
message: chalk.yellow('ok so the first question \n why do you want to be my friend ? \n'),
choices: [
'because i have no friends',
'because you have no friends',
'because we will grow together',
'because we are classmate'
],
});
answers.question1 == 'because we will grow together';
return handleAnswer1(answers.question1 == 'because we will grow together' );
}
async function question2() {
console.clear();
const answers = await inquirer.prompt ({
name: 'question2',
type: 'list',
message: chalk.yellow('next question: \n let me check how well you know me!! \n tell me what is my hobby'),
choices: [
'coding',
'photography',
'videography',
'public speaking'
],
});
answers.question1 == 'because we will grow together';
return handleAnswer2(answers.question2 == 'coding' );
}
async function question3() {
console.clear();
const answers = await inquirer.prompt ({
name: 'question3',
type: 'list',
message: chalk.yellow('Okay !! you know me, still i want to know how you can help me ? \n becuse i have no time to waste with wrong guys \n'),
choices: [
'i will help you in finding internship',
'i will help in your bad times with emotional support',
'i will help you by helping you to make new gf',
'hehe !!, i will never help you but i will show you the path'
],
});
return handleAnswer3(answers.question3 == 'hehe !!, i will never help you but i will show you the path' );
}
async function question4() {
console.clear();
const answers = await inquirer.prompt ({
name: 'question4',
type: 'list',
message: chalk.yellow(`Good going ${Gender} ${player} \n One last question what i dislike the most ? \n`),
choices: [
'not doing the thing which is important for me',
'work for society',
'loving a person',
'put efforts'
],
});
return handleAnswer4(answers.question4 == 'not doing the thing which is important for me' );
}
// it will return a boolean either it is correct or incorrect
async function handleAnswer1(isCorrect) {
const Spinner = createSpinner('checking answer...').start();
await sleep();
if(isCorrect){
Spinner.success({text : `I like it, ${player} !!`});
await sleep();
}
else {
Spinner.error({text : `game over ${Gender} ${player}. you can't be my friend !!`});
process.exit(1);
}
}
async function handleAnswer2(isCorrect) {
const Spinner = createSpinner('checking answer...').start();
await sleep();
if(isCorrect){
Spinner.success({text : `Gud job, ${Gender} ${player} !!`});
await sleep();
}
else {
Spinner.error({text : `game over ${Gender} ${player}. you can't be my friend !!`});
process.exit(1);
}
}
async function handleAnswer3(isCorrect) {
const Spinner = createSpinner('checking answer...').start();
await sleep();
if(isCorrect){
Spinner.success({text : `you are toally my type, yaar !!`});
await sleep();
}
else {
Spinner.error({text : `game over ${Gender} ${player}. you can't be my friend !!`});
process.exit(1);
}
}
async function handleAnswer4(isCorrect) {
const Spinner = createSpinner('checking answer...').start();
await sleep();
if(isCorrect){
Spinner.success();
await winner();
}
else {
Spinner.error({text : `game over ${Gender} ${player}. you can't be my friend !!`});
process.exit(1);
}
}
const sleep2 = (ms = 500) => new Promise((r)=>setTimeout(r,ms))
const sleep3 = (ms = 10000) => new Promise((r)=>setTimeout(r,ms))
async function handlelast() {
await sleep2();
const Spinner = createSpinner('a present...').start();
await sleep();
await sleep();
Spinner.success();
}
async function winner(){
console.clear();
const msg = `Congrats ${player} !`;
const msg2 = `Surajj 🤝 ${player}`
figlet(msg, (err, data)=>{
console.log(gradient.pastel.multiline(data));
if(`${player}`==='Agrim' || `${player}`==='agrim' ){
console.log(gradient.passion.multiline(`\n you are my best friends.`));
}
else if (`${player}` === 'Jyoti' || `${player}` === 'jyoti' || `${player}` === 'Jyoti km' || `${player}` === 'jyoti km'){
console.log(gradient.passion.multiline(`\n you are my love,i love you jaan`));
}
else if (`${player}` === 'Kamal' || `${player}` === 'kamal' || `${player}` === 'saka' || `${player}` === 'kamalnayan' || `${player}` === 'kamal nayan' || `${player}` === 'Kamal Nayan' || `${player}` === 'Kamal nayan' || `${player}` === 'KamalNayan' ){
console.log(gradient.passion.multiline(`\n you are my brother`));
}
else if (`${player}` === 'niraj' || `${player}` === 'Niraj' || `${player}` === 'niraj pandey' || `${player}` === 'Niraj pandey' ){
console.log(gradient.passion.multiline(`\n you are my brother`));
}
else{
console.log(gradient.passion.multiline(`\n we are friends, Now !!`));
}
})
await handlelast();
figlet(msg2, (err,data)=>{
console.log(gradient.passion.multiline(data));
})
await sleep3();
}
await welcome();
await playername();
await askGender();
await question1();
await question2();
await question3();
await question4();
//npm version patch
//npm publish