-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
64 lines (47 loc) · 1.25 KB
/
main.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
if (WP === undefined)
var WP = {};
// CONFIG
WP.name = 'Wrinkler Popper';
WP.release = 1;
WP.interval = 1000 * 5;
WP.getTheFattestWrinklerId = function() {
let theFattestWrinklerId = undefined;
for (let i = 0; i < Game.wrinklers.length; i++) {
let currentWrinkler = Game.wrinklers[i];
let { sucked } = Game.wrinklers[i];
// wrinkler.type = 1 => Shiny
if (currentWrinkler.type || !sucked)
continue;
if (theFattestWrinklerId === undefined) {
theFattestWrinklerId = i;
continue;
}
if (sucked > Game.wrinklers[theFattestWrinklerId].sucked)
theFattestWrinklerId = i;
}
return theFattestWrinklerId;
}
WP.getSuckingWrinklers = function() {
let getSuckingWrinklers = 0;
Game.wrinklers.forEach(wrinkler => {
if (wrinkler.sucked)
getSuckingWrinklers++;
});
return getSuckingWrinklers;
}
WP.init = function() {
setInterval(function() {
if (Game.getWrinklersMax() === WP.getSuckingWrinklers()) {
let theFattestWrinklerId = WP.getTheFattestWrinklerId();
console.log(theFattestWrinklerId);
if (theFattestWrinklerId !== undefined)
Game.wrinklers[theFattestWrinklerId].hp = 0;
}
}, this.interval);
Game.Notify(
`${this.name} R${this.release} loaded successfully`,
'',
[16,5]
);
}
Game.registerMod(WP.name, WP);