From 61bb9393231e9b5874f824d37dc93679caa3dba3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 15 Jan 2023 16:48:26 +0100 Subject: Crimson mini Boss support. --- .../CrimsonIsleReputationHelper.kt | 21 ++++++- .../reputationhelper/dailyquest/CrimsonMiniBoss.kt | 3 + .../dailyquest/DailyMiniBossHelper.kt | 67 ++++++++++++++++++++++ .../dailyquest/DailyQuestHelper.kt | 24 +++++++- .../reputationhelper/dailyquest/QuestLoader.kt | 9 +-- .../reputationhelper/dailyquest/quest/BossQuest.kt | 4 -- .../dailyquest/quest/MiniBossQuest.kt | 6 ++ .../dailyquest/quest/QuestCategory.kt | 4 +- 8 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/CrimsonMiniBoss.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyMiniBossHelper.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/BossQuest.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/nether') diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 4cbea0f23..66fef9c0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.CrimsonMiniBoss +import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyMiniBossHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings @@ -13,10 +15,23 @@ import net.minecraftforge.fml.common.gameevent.TickEvent class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { - private val questHelper = DailyQuestHelper(this) + val questHelper = DailyQuestHelper(this) + private val miniBossHelper = DailyMiniBossHelper(this) + + val miniBosses = mutableListOf() init { skyHanniMod.loadModule(questHelper) + skyHanniMod.loadModule(miniBossHelper) + + miniBosses.add(CrimsonMiniBoss("Magma Boss")) + miniBosses.add(CrimsonMiniBoss("Mage Outlaw")) + miniBosses.add(CrimsonMiniBoss("Barbarian Duke X")) + + miniBosses.add(CrimsonMiniBoss("Bladesoul")) + miniBosses.add(CrimsonMiniBoss("Ashfang")) + + miniBossHelper.init() } private val display = mutableListOf() @@ -36,8 +51,8 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { display.clear() display.add("Reputation Helper:") - display.add("") - questHelper.renderAllQuests(display) + questHelper.render(display) + miniBossHelper.render(display) } @SubscribeEvent(priority = EventPriority.LOWEST) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/CrimsonMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/CrimsonMiniBoss.kt new file mode 100644 index 000000000..a9442d4fb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/CrimsonMiniBoss.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest + +class CrimsonMiniBoss(val displayName: String) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyMiniBossHelper.kt new file mode 100644 index 000000000..fbad68508 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyMiniBossHelper.kt @@ -0,0 +1,67 @@ +package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest + +import at.hannibal2.skyhanni.data.HyPixelData +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { + + private val miniBossesDoneToday = mutableMapOf() + private val miniBossesPatterns = mutableMapOf() + + fun init() { + for (miniBoss in reputationHelper.miniBosses) { + miniBossesDoneToday[miniBoss] = false + val patterns = " *§r§6§l${miniBoss.displayName.uppercase()} DOWN!" + println("patterns: '$patterns'") + miniBossesPatterns[miniBoss] = Pattern.compile(patterns) + } + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!HyPixelData.skyBlock) return + if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return + + val message = event.message + for (entry in miniBossesPatterns) { + val pattern = entry.value + if (pattern.matcher(message).matches()) { + finished(entry.key) + } + //§r§6§BLADESOUL DOWN! + } + // §r§6§lMAGMA BOSS DOWN! + // §r§6§lMAGE OUTLAW DOWN! + } + + private fun finished(miniBoss: CrimsonMiniBoss) { + LorenzUtils.debug("Detected mini boss death: ${miniBoss.displayName}") + reputationHelper.questHelper.finishMiniBoss(miniBoss) + miniBossesDoneToday[miniBoss] = true + reputationHelper.update() + } + + fun render(display: MutableList) { + val done = miniBossesDoneToday.count { it.value } +// val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking +// if (done != 5 || sneaking) { + if (done != 5) { + display.add("") + display.add("Daily Bosses ($done/5 killed)") + for (entry in miniBossesDoneToday) { + display.add(renderQuest(entry.key, entry.value)) + } + } + } + + private fun renderQuest(miniBoss: CrimsonMiniBoss, doneToday: Boolean): String { + val color = if (doneToday) "§7Done" else "§bTodo" + val displayName = miniBoss.displayName + return "$displayName: $color" + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index dababf56e..3b36c83b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -19,7 +19,7 @@ import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper) { +class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { val quests = mutableListOf() private var tick = 0 @@ -203,11 +203,12 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper update() } - fun renderAllQuests(display: MutableList) { + fun render(display: MutableList) { val done = quests.count { it.state == QuestState.COLLECTED } // val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking // if (done != 5 || sneaking) { if (done != 5) { + display.add("") display.add("Daily Quests ($done/5 collected)") for (quest in quests) { // if (!sneaking) { @@ -248,6 +249,23 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper } else { "" } - return "$stateColor[$state] §f$type: §f$displayName$multipleText$sacksText" + + val stateText = if (quest !is UnknownQuest) { + "$stateColor[$state] §f" + } else { + "" + } + + return "$stateText$type: §f$displayName$multipleText$sacksText" + } + + fun finishMiniBoss(miniBoss: CrimsonMiniBoss) { + val miniBossQuest = getQuest() ?: return + if (miniBossQuest.miniBoss == miniBoss) { + if (miniBossQuest.state == QuestState.READY_TO_COLLECT) { + miniBossQuest.state = QuestState.COLLECTED + updateProcessQuest(miniBossQuest, miniBossQuest.haveAmount + 1) + } + } } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index 54282e21b..3d7c2b10a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -91,10 +91,11 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { //Rescue Mission if (name == "Rescue Mission") return RescueMissionQuest(state) - //Boss - if (name == "Magma Boss") return BossQuest(name, state, amount) - if (name == "Mage Outlaw") return BossQuest(name, state, amount) - if (name == "Barbarian Duke X") return BossQuest(name, state, amount) + for (miniBoss in dailyQuestHelper.reputationHelper.miniBosses) { + if (name == miniBoss.displayName) { + return MiniBossQuest(miniBoss, state, amount) + } + } //Fetch if (name == "Magmag") return FetchQuest(name, state, amount) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/BossQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/BossQuest.kt deleted file mode 100644 index c6f469243..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/BossQuest.kt +++ /dev/null @@ -1,4 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest - -class BossQuest(bossName: String, state: QuestState, needAmount: Int) : - ProgressQuest(QuestCategory.MINIBOSS, bossName, state, needAmount) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt new file mode 100644 index 000000000..d09b28f95 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest + +import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.CrimsonMiniBoss + +class MiniBossQuest(val miniBoss: CrimsonMiniBoss, state: QuestState, needAmount: Int) : + ProgressQuest(QuestCategory.MINIBOSS, miniBoss.displayName, state, needAmount) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/QuestCategory.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/QuestCategory.kt index 29645f9b5..933c5c007 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/QuestCategory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/QuestCategory.kt @@ -3,9 +3,9 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest enum class QuestCategory(val displayName: String) { FISHING("Trophy Fish"), RESCUE("Rescue Mission"), - MINIBOSS("Crimson Boss"), + MINIBOSS("Mini Boss"), FETCH("Item Fetch"), - DOJO("Dojo"), + DOJO("Dojo Task"), UNKNOWN("§cUnknown"), } \ No newline at end of file -- cgit