From a2266a87073622b6547b3704f7ad81de0f6cb5b2 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 21 Jul 2024 11:16:24 +0200 Subject: Fix: Slayer detection (#2232) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/slayer/SlayerQuestWarning.kt | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index a5f8af5c7..52afc0256 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -61,20 +61,21 @@ object SlayerQuestWarning { private fun getSlayerData() = if (RiftAPI.inRift()) outsideRiftData else insideRiftData + private fun String.inCombat() = contains("Combat") || contains("Kills") + private fun String.inBoss() = this == "Slay the boss!" + private fun String?.bossSlain() = this == "Boss slain!" + private fun String.noSlayer() = this == "no slayer" + private fun change(old: String, new: String) { - if (new.contains("Combat")) { - if (!old.contains("Combat")) { - needSlayerQuest = false - } + if (!old.inCombat() && new.inCombat()) { + needSlayerQuest = false } - if (new == "no slayer") { - if (old == "Slay the boss!") { - needNewQuest("The old slayer quest has failed!") - } + if (old.inBoss() && new.noSlayer()) { + needNewQuest("The old slayer quest has failed!") } - if (new == "Boss slain!") { + if (new.bossSlain()) { DelayedRun.runDelayed(2.seconds) { - if (getSlayerData().currentSlayerState == "Boss slain!") { + if (getSlayerData().currentSlayerState.bossSlain()) { needNewQuest("You have no Auto-Slayer active!") } } @@ -133,7 +134,7 @@ object SlayerQuestWarning { SlayerAPI.latestWrongAreaWarning = SimpleTimeMark.now() warn( "Wrong Slayer!", - "Wrong slayer selected! You have $activeSlayerName selected and you are in an $slayerName area!" + "Wrong slayer selected! You have $activeSlayerName selected and you are in an $slayerName area!", ) } } -- cgit