aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-12-12 19:02:53 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-12-12 19:02:53 +0800
commit243403b0274956c2e781392d07a785386354f1c5 (patch)
tree72bfc65a809c6b8babc78bc3c5d03c4cdf2ccb40
parent03d36c785965434556b9c8e060de8758900f5004 (diff)
downloadSoopyV2-243403b0274956c2e781392d07a785386354f1c5.tar.gz
SoopyV2-243403b0274956c2e781392d07a785386354f1c5.tar.bz2
SoopyV2-243403b0274956c2e781392d07a785386354f1c5.zip
fix incorrect rank changing calculations
-rw-r--r--features/lockedFeatures/index.js14
-rw-r--r--utils/numberUtils.js7
2 files changed, 14 insertions, 7 deletions
diff --git a/features/lockedFeatures/index.js b/features/lockedFeatures/index.js
index 551922b..04ac729 100644
--- a/features/lockedFeatures/index.js
+++ b/features/lockedFeatures/index.js
@@ -5,7 +5,7 @@ import ToggleSetting from "../settings/settingThings/toggle";
import SoopyV2Server from "../../socketConnection"
import HudTextElement from "../hud/HudTextElement";
import LocationSetting from "../settings/settingThings/location";
-import { numberWithCommas, timeNumber, timeSince } from "../../utils/numberUtils";
+import { numberWithCommas, timeNumber2, timeSince } from "../../utils/numberUtils";
class LockedFeatures extends Feature {
constructor() {
@@ -70,17 +70,17 @@ class LockedFeatures extends Feature {
let timeTillIncrease = Infinity
let timeTillDecrease = Infinity
if(nextProgress[1]-playerProgress[1] < 0){
- timeTillIncrease = Math.abs((nextProgress[0]-playerProgress[0])/(nextProgress[1]-playerProgress[1])*60*60*1000)
+ timeTillIncrease = ((nextProgress[0]-playerProgress[0])/(playerProgress[1]-nextProgress[1])*60*60*1000)
}
if(prevProgress[1]-playerProgress[1] < 0){
- timeTillDecrease = Math.abs((prevProgress[0]-playerProgress[0])/(prevProgress[1]-playerProgress[1])*60*60*1000)
+ timeTillDecrease = ((playerProgress[0]-prevProgress[0])/(prevProgress[1]-playerProgress[1])*60*60*1000)
}
- if(timeTillIncrease < timeTillDecrease && timeTillIncrease < 10000000000){
- text = "&dRank increasing in ~" + timeNumber(timeTillIncrease) + "\n"+text
+ if((timeTillIncrease < timeTillDecrease || (timeTillIncrease > 0)) && timeTillDecrease < 0 && timeTillIncrease < 10000000000){
+ text = "&d ^ in " + timeNumber2(timeTillIncrease) + "\n"+text
}
- if(timeTillIncrease > timeTillDecrease && timeTillDecrease < 10000000000){
- text = "&dRank decreasing in ~" + timeNumber(timeTillDecrease) + "\n"+text
+ if((timeTillIncrease > timeTillDecrease || (timeTillDecrease>0))&&timeTillIncrease<0 && timeTillDecrease < 10000000000){
+ text = "&d V in " + timeNumber2(timeTillDecrease) + "\n"+text
}
this.guildLbElement.setText(text)
diff --git a/utils/numberUtils.js b/utils/numberUtils.js
index 1258d90..96a6b74 100644
--- a/utils/numberUtils.js
+++ b/utils/numberUtils.js
@@ -82,5 +82,12 @@ module.exports = {
if(mins === 0) return secs + "s"
return `${mins}m ${secs}s`
+ },
+ timeNumber2: function(time){
+ let hours = Math.floor(time/1000/60/60)
+ let mins = Math.floor(time/1000/60)%60
+
+ if(hours === 0) return mins + "m"
+ return `${hours}h ${mins}m`
}
} \ No newline at end of file