aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt26
1 files changed, 23 insertions, 3 deletions
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 fefc5cf0c..9a709e43b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.data.jsonobjects.repo.SlayerProfitTrackerItemsJson
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ItemAddEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PurseChangeCause
import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
@@ -18,8 +19,11 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData
import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker
import com.google.gson.JsonObject
@@ -35,6 +39,14 @@ object SlayerProfitTracker {
private var baseSlayerType = ""
private val trackers = mutableMapOf<String, SkyHanniItemTracker<Data>>()
+ /**
+ * REGEX-TEST: §7Took 1.9k coins from your bank for auto-slayer...
+ */
+ private val autoSlayerBankPattern by RepoPattern.pattern(
+ "slayer.autoslayer.bank.chat",
+ "§7Took (?<coins>.+) coins from your bank for auto-slayer\\.\\.\\."
+ )
+
class Data : ItemTrackerData() {
override fun resetItems() {
@@ -71,9 +83,9 @@ object SlayerProfitTracker {
private val ItemTrackerData.TrackedItem.timesDropped get() = timesGained
- private fun addSlayerCosts(price: Int) {
+ private fun addSlayerCosts(price: Double) {
getTracker()?.modify {
- it.slayerSpawnCost += price
+ it.slayerSpawnCost += price.toInt()
}
}
@@ -92,7 +104,15 @@ object SlayerProfitTracker {
getTracker()?.addCoins(coins.toInt())
}
if (event.reason == PurseChangeCause.LOSE_SLAYER_QUEST_STARTED) {
- addSlayerCosts(coins.toInt())
+ addSlayerCosts(coins)
+ }
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ autoSlayerBankPattern.matchMatcher(event.message) {
+ addSlayerCosts(group("coins").formatDouble())
}
}