From f4831bff1bf50570898b0d07524d6d605d958283 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:44:06 +0100 Subject: Fixed dice roll profit counting as Mob Kill Coins in Slayer Tracker. --- src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt | 13 +++++++++++-- .../java/at/hannibal2/skyhanni/events/PurseChangeEvent.kt | 4 +++- src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index cb3b21031..0deb53164 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.milion import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -41,12 +42,16 @@ class PurseAPI { if (diff == 1.0) { return PurseChangeCause.GAIN_TALISMAN_OF_COINS } + + if (diff == 15.milion || diff == 100.milion) { + return PurseChangeCause.GAIN_DICE_ROLL + } + if (Minecraft.getMinecraft().currentScreen == null) { val timeDiff = System.currentTimeMillis() - inventoryCloseTime if (timeDiff > 2_000) { return PurseChangeCause.GAIN_MOB_KILL } - } return PurseChangeCause.GAIN_UNKNOWN } else { @@ -55,7 +60,11 @@ class PurseAPI { return PurseChangeCause.LOSE_SLAYER_QUEST_STARTED } + if (diff == -6_666_666.0 || diff == -666_666.0) { + return PurseChangeCause.LOSE_DICE_ROLL_COST + } + return PurseChangeCause.LOSE_UNKNOWN } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/PurseChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PurseChangeEvent.kt index 50343a7d9..d776fe32b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PurseChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PurseChangeEvent.kt @@ -5,8 +5,10 @@ class PurseChangeEvent(val coins: Double, val reason: PurseChangeCause) : Lorenz enum class PurseChangeCause { GAIN_MOB_KILL, GAIN_TALISMAN_OF_COINS, + GAIN_DICE_ROLL, GAIN_UNKNOWN, LOSE_SLAYER_QUEST_STARTED, + LOSE_DICE_ROLL_COST, LOSE_UNKNOWN, -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 3ad9e2da7..707bb5b4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -201,4 +201,7 @@ object NumberUtil { val d = text.toDouble() return (d * multiplier).toLong() } -} \ No newline at end of file + + val Int.milion get() = this * 1_000_000.0 + val Double.milion get() = (this * 1_000_000.0).toLong() +} -- cgit