-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamogus.js
81 lines (68 loc) · 2.22 KB
/
amogus.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
class AMOGUS {
constructor(crewmates) {
/**
* @param {crewmates} Array Array of crewmates
*
*/
if(!Array.isArray(crewmates)){
throw 'Please provide a valid array!'
} else if(crewmates.length > 10){
throw "10 is the maximum crewmates."
}
this.crewmates = crewmates;
}
sussify(){
/**
* This will sussify the crewmates.
* Returns sus crewmates;
*/
this.sussified = true;
this.sus = this.crewmates[Math.floor(Math.random() * this.crewmates.length)];
return this.sus
}
eject(){
const eject_promise = new Promise((resolve, reject) => {
if(!this.sussified){
reject('SUSSIFY THE CREWMATES IN ORDER TO EJECT THEM!');
}
if(!this.meeting){
reject('MAKE SURE YOU HAVE DONE EMERGENCY MEETING IN ORDER TO EJECT IMPASTA!');
}
try {
let random = Math.floor(Math.random() * 1);
if(random === 0){
this.impostor = this.evenMoreSus;
} else if(random === 1){
this.impostor = this.sus;
}
} catch {
throw 'stop!';
}
this.crewmates.splice(this.crewmates.indexOf(this.impostor), 1);
resolve(`EJECTED IMPOSTOR 😳 | IMPOSTOR WAS ${this.impostor}`);
});
return eject_promise;
/**
* This will eject the crewmate who is sus. Make sure you sussify and run an emergency meeting.
* @returns String Impostor
* Promise String
*/
}
emergency_meeting(){
const emergency_promise = new Promise((resolve, reject) => {
if(!this.sussified){
reject('SUSSIFY THE CREWMATES IN ORDER TO EJECT THEM!');
}
this.meeting = true
this.evenMoreSus = this.sussify();
resolve(this.evenMoreSus);
})
/**
* This will run an emergency meeting.
* @returns String Even more sus crewmate
* Promise String
*/
return emergency_promise;
}
}
module.exports = AMOGUS;