aboutsummaryrefslogtreecommitdiff
path: root/socketConnection.js
diff options
context:
space:
mode:
Diffstat (limited to 'socketConnection.js')
-rw-r--r--socketConnection.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/socketConnection.js b/socketConnection.js
index a55e834..680bb4f 100644
--- a/socketConnection.js
+++ b/socketConnection.js
@@ -19,6 +19,17 @@ class SoopyV2Server extends WebsiteCommunicator {
this.onPlayerStatsLoaded = undefined
this.userCosmeticPermissions = undefined
+
+ this.cookieCount = 0
+ this.cookieData = undefined
+ this.cookieDataUpdated = 0
+
+ register("step", () => {
+ if (this.cookieDataUpdated && Date.now() - this.cookieDataUpdated > 60000) {
+ this.cookieData = 0
+ this.cookieDataUpdated = 0
+ }
+ }).setDelay(60)
}
onData(data) {
@@ -48,6 +59,17 @@ class SoopyV2Server extends WebsiteCommunicator {
if (data.type === "inquisData") {
if (global.soopyv2featuremanagerthing && global.soopyv2featuremanagerthing.features.events) global.soopyv2featuremanagerthing.features.events.class.inquisData(data.location, data.user)
}
+ if (data.type === "cookies") {
+ this.cookieCount = data.cookies
+ }
+ if (data.type === "cookieLbData") {
+ this.cookieData = {
+ cookieLeaderboard: data.cookieLeaderboard,
+ clickingNow: data.clickingNow
+ }
+
+ this.cookieDataUpdated = Date.now()
+ }
}
onConnect() {
@@ -150,6 +172,15 @@ class SoopyV2Server extends WebsiteCommunicator {
server: server
})
}
+
+ cookiesGained(amount) {
+ this.cookieCount += amount
+
+ this.sendData({
+ type: "cookies",
+ amount: amount
+ })
+ }
}
if (!global.soopyV2Server) {