aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt14
4 files changed, 18 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
index 67468351f..5b8776bec 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
@@ -81,19 +81,7 @@ object DianaProfitTracker {
)
)
- val profitFormat = profit.addSeparators()
- val profitPrefix = if (profit < 0) "§c" else "§6"
-
- val profitPerBurrow = profit / data.burrowsDug
- val profitPerBurrowFormat = NumberUtil.format(profitPerBurrow)
-
- val text = "§eTotal Profit: $profitPrefix$profitFormat coins"
- addAsSingletonList(
- Renderable.hoverTips(
- text,
- listOf("§7Profit per burrow: $profitPrefix$profitPerBurrowFormat")
- )
- )
+ addAsSingletonList(tracker.addTotalProfit(profit, data.burrowsDug, "burrow"))
tracker.addPriceFromButton(this)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
index 979fa845f..1ccac83de 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
@@ -112,14 +112,7 @@ object FishingProfitTracker {
)
)
- val profitFormat = profit.addSeparators()
- val profitPrefix = if (profit < 0) "§c" else "§6"
-
- val profitPerCatch = profit / data.totalCatchAmount
- val profitPerCatchFormat = NumberUtil.format(profitPerCatch)
-
- val text = "§eTotal Profit: $profitPrefix$profitFormat coins"
- addAsSingletonList(Renderable.hoverTips(text, listOf("§7Profit per catch: $profitPrefix$profitPerCatchFormat")))
+ addAsSingletonList(tracker.addTotalProfit(profit, data.totalCatchAmount, "catch"))
tracker.addPriceFromButton(this)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
index 6ff20129b..d0c374a8b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
@@ -43,7 +43,7 @@ object SlayerProfitTracker {
var slayerSpawnCost: Long = 0
@Expose
- var slayerCompletedCount = 0
+ var slayerCompletedCount = 0L
override fun getDescription(timesDropped: Long): List<String> {
val percentage = timesDropped.toDouble() / slayerCompletedCount
@@ -168,14 +168,7 @@ object SlayerProfitTracker {
)
)
- val profitFormat = profit.addSeparators()
- val profitPrefix = if (profit < 0) "§c" else "§6"
-
- val profitPerBoss = profit / itemLog.slayerCompletedCount
- val profitPerBossFormat = NumberUtil.format(profitPerBoss)
-
- val text = "§eTotal Profit: $profitPrefix$profitFormat coins"
- addAsSingletonList(Renderable.hoverTips(text, listOf("§7Profit per boss: $profitPrefix$profitPerBossFormat")))
+ addAsSingletonList(tracker.addTotalProfit(profit, itemLog.slayerCompletedCount, "boss"))
tracker.addPriceFromButton(this)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt
index 8dab120fa..b831ade3f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt
@@ -172,4 +172,18 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
}
}
+ fun addTotalProfit(profit: Double, totalAmount: Long, action: String): Renderable {
+ val profitFormat = profit.addSeparators()
+ val profitPrefix = if (profit < 0) "§c" else "§6"
+
+ val tips = if (totalAmount > 0) {
+ val profitPerCatch = profit / totalAmount
+ val profitPerCatchFormat = NumberUtil.format(profitPerCatch)
+ listOf("§7Profit per $action: $profitPrefix$profitPerCatchFormat")
+ } else emptyList()
+
+ val text = "§eTotal Profit: $profitPrefix$profitFormat coins"
+ return Renderable.hoverTips(text, tips)
+ }
+
}