This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.js
127 lines (119 loc) · 2.3 KB
/
button.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
const fs = require("fs")
if(!fs.existsSync("./data.json")){
let defaultData = {
health: 360,
isAlive: true,
healthLevel: 6
}
fs.writeFileSync("./data.json", JSON.stringify(defaultData, null, 4))
}
const data = require("./data.json")
const ranks = [
{
name: "A normal Vukky",
maxHealth: 360,
minHealth: 291,
role: "986183600514940978"
},
{
name: "Kind of a cool person",
maxHealth: 290,
minHealth: 221,
role: "986183740126527558"
},
{
name: "Cool person",
maxHealth: 220,
minHealth: 161,
role: "986183886272872468"
},
{
name: "Button fanatic",
maxHealth: 160,
minHealth: 101,
role: "986183997388365834"
},
{
name: "Row-bot",
maxHealth: 100,
minHealth: 41,
role: "986184105051947028"
},
{
name: "niko",
maxHealth: 40,
minHealth: 21,
role: "986184227177496616"
},
{
name: "h",
maxHealth: 20,
minHealth: 11,
role: "995604770888892447"
},
{
name: "no pls",
maxHealth: 10,
minHealth: 2,
role: "995605245176590387"
},
{
name: "touch grass",
maxHealth: 1,
minHealth: 1,
role: "995605690838159360"
}
]
// Hello, It's me again. I am not sure this is the smartest way but it doesnt actually really matter.
function init() {
var healthDecrease = setInterval(() => {
if(data.health <= 1){
data.isAlive = false
data.health = 0
data.healthLevel = "dead"
clearInterval(healthDecrease)
} else {
data.health -= 1
data.healthLevel = getRank(data.health).name
}
console.log("Health decreased! Now: ", data.health)
fs.writeFileSync("./data.json", JSON.stringify(data, null, 4))
//}, 30000)
}, 5000)
}
function getRank(health) {
for(let rank in ranks){
if(health >= ranks[rank].minHealth && health <= ranks[rank].maxHealth){
return ranks[rank]
}
}
}
function slapthebutton() {
if(data.isAlive){
let rank = getRank(data.health)
data.health = 360
data.healthLevel = getRank(data.health).name
fs.writeFileSync("./data.json", JSON.stringify(data, null, 4))
return {rank: rank}
} else {
return {message: "Pressing a dead button wont help..."}
}
}
function isAlive() {
return data.isAlive
}
function health() {
return data.health
}
function healthLevel() {
return data.healthLevel
}
module.exports = {
getRank,
init,
slapthebutton,
isAlive: isAlive,
health: health,
healthLevel: healthLevel,
ranks: ranks
}