aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-10-11 11:24:39 +0100
committerGitHub <noreply@github.com>2023-10-11 12:24:39 +0200
commit4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7 (patch)
tree80d0ba5a1fa2893c0529f0382a99d6a044bc905c /src/main/java/at/hannibal2/skyhanni/utils
parent8527d7555ea16becbcfe949413eabfd41c8400c4 (diff)
downloadskyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.tar.gz
skyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.tar.bz2
skyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.zip
More Code Cleanup - When (#531)
code cleanup #531
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
index 3bf5ff2f6..52916b98d 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
@@ -38,33 +38,35 @@ object CombatUtils {
if (lastTotalXp > 0) {
val delta: Float = totalXp - lastTotalXp
- if (delta > 0 && delta < 1000) {
- xpGainTimer = GhostCounter.config.pauseTimer
- xpGainQueue.add(0, delta)
- while (xpGainQueue.size > 30) {
- xpGainQueue.removeLast()
+ when {
+ delta > 0 && delta < 1000 -> {
+ xpGainTimer = GhostCounter.config.pauseTimer
+ xpGainQueue.add(0, delta)
+ calculateXPHour()
}
- var totalGain = 0f
- for (f in xpGainQueue) totalGain += f
- xpGainHour = totalGain * (60 * 60) / xpGainQueue.size
- isKilling = true
- } else if (xpGainTimer > 0) {
- xpGainTimer--
- xpGainQueue.add(0, 0f)
- while (xpGainQueue.size > 30) {
- xpGainQueue.removeLast()
+ xpGainTimer > 0 -> {
+ xpGainTimer--
+ xpGainQueue.add(0, 0f)
+ calculateXPHour()
+ }
+ delta <= 0 -> {
+ isKilling = false
}
- var totalGain = 0f
- for (f in xpGainQueue) totalGain += f
- xpGainHour = totalGain * (60 * 60) / xpGainQueue.size
- isKilling = true
- } else if (delta <= 0) {
- isKilling = false
}
}
lastTotalXp = totalXp
}
+ private fun calculateXPHour(){
+ while (xpGainQueue.size > 30) {
+ xpGainQueue.removeLast()
+ }
+ var totalGain = 0f
+ for (f in xpGainQueue) totalGain += f
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size
+ isKilling = true
+ }
+
fun calculateETA() {
lastKillUpdate = System.currentTimeMillis()
killGainHourLast = killGainHour