Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Draconic Sacrifice Tracker #2077

Open
wants to merge 21 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/dictionaries/default_user.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker
import at.hannibal2.skyhanni.features.minion.MinionFeatures
import at.hannibal2.skyhanni.features.misc.CarryTracker
import at.hannibal2.skyhanni.features.misc.CollectionTracker
import at.hannibal2.skyhanni.features.misc.DraconicSacrificeTracker
import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.features.misc.TpsCounter
Expand Down Expand Up @@ -252,7 +253,8 @@ object Commands {
) { FarmingWeightDisplay.lookUpCommand(it) }
registerCommand(
"shcopytranslation",
"Copy the English translation of a message in another language to the clipboard.\n" + "Uses a 2 letter language code that can be found at the end of a translation message.",
"Copy the English translation of a message in another language to the clipboard.\n" +
"Uses a 2 letter language code that can be found at the end of a translation message.",
) { Translator.fromEnglish(it) }
registerCommand(
"shtranslate",
Expand All @@ -278,6 +280,10 @@ object Commands {
"shresetpestprofittracker",
"Resets the Pest Profit Tracker",
) { PestProfitTracker.resetCommand() }
registerCommand(
"sheresetsacrificeprofittracker",
"Resets the Sacrifice Profit Tracker",
) { DraconicSacrificeTracker.resetCommand() }
registerCommand(
"shresetexperimentsprofittracker",
"Resets the Experiments Profit Tracker",
Expand Down Expand Up @@ -591,7 +597,9 @@ object Commands {
) { TitleManager.command(it) }
registerCommand(
"shresetconfig",
"Reloads the config manager and rendering processors of MoulConfig. " + "This §cWILL RESET §7your config, but also updating the java config files " + "(names, description, orderings and stuff).",
"Reloads the config manager and rendering processors of MoulConfig. " +
"This §cWILL RESET §7your config, but also updating the java config files " +
"(names, description, orderings and stuff).",
) { SkyHanniDebugsAndTests.resetConfigCommand() }
registerCommand(
"shreadcropmilestonefromclipboard",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package at.hannibal2.skyhanni.config.features.misc;

import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

public class DraconicSacrificeTrackerConfig {

@Expose
@ConfigOption(name = "Enable", desc = "Enable the Draconic sacrifice tracker.")
superhize marked this conversation as resolved.
Show resolved Hide resolved
@ConfigEditorBoolean
superhize marked this conversation as resolved.
Show resolved Hide resolved
public boolean enabled = true;

@Expose
@ConfigOption(name = "Only In Void Slate", desc = "Show the tracker only when inside the Void Slate area.")
@ConfigEditorBoolean
public boolean onlyInVoidSlate = true;

@Expose
@ConfigLink(owner = DraconicSacrificeTrackerConfig.class, field = "enabled")
public Position position = new Position(201, 199, false, true);

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public class MiscConfig {
public PatcherCoordsWaypointConfig patcherCoordsWaypoint = new PatcherCoordsWaypointConfig();

@Expose
@ConfigOption(name = "Dragonic Sacrifice Tracker", desc = "")
@Accordion
public DraconicSacrificeTrackerConfig draconicSacrificeTracker = new DraconicSacrificeTrackerConfig();
superhize marked this conversation as resolved.
Show resolved Hide resolved
@ConfigOption(name = "Reminders", desc = "")
@Accordion
public RemindersConfig reminders = new RemindersConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker;
import at.hannibal2.skyhanni.features.mining.glacitemineshaft.CorpseTracker;
import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker;
import at.hannibal2.skyhanni.features.misc.DraconicSacrificeTracker;
import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker;
import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker;
import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal;
Expand Down Expand Up @@ -717,6 +718,9 @@ public static class WardrobeStorage {
public Integer currentSlot = null;
}

@Expose
public DraconicSacrificeTracker.Data draconicSacrificeTracker = new DraconicSacrificeTracker.Data();

@Expose
public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString
import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.renderables.Searchable
import at.hannibal2.skyhanni.utils.renderables.toSearchable
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.annotations.Expose
import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object DraconicSacrificeTracker {

private val config get() = SkyHanniMod.feature.misc.draconicSacrificeTracker
private val patternGroup = RepoPattern.group("misc.draconicsacrifice")
private val sacrificeLoot by patternGroup.pattern(
"sacrifice",
"§c§lSACRIFICE! §r§eYou turned §r(?<item>.*) §r§einto §r§d(?<amount>\\d+) Dragon Essence§r§e!",
)
private val bonusLoot by patternGroup.pattern(
"bonus",
"§c§lBONUS LOOT! §r§eYou also received §r(?:§\\w(?<amount>\\d+)?x)?(?: §r)?(?<item>.*) §r§efrom your sacrifice!",
)
superhize marked this conversation as resolved.
Show resolved Hide resolved

private val tracker =
SkyHanniItemTracker("Draconic Sacrifice Profit Tracker", { Data() }, { it.draconicSacrificeTracker }) {
drawDisplay(it)
}

private val altarArea = AxisAlignedBB(-601.0, 4.0, -282.0, -586.0, 15.0, -269.0)

class Data : ItemTrackerData() {
override fun resetItems() {
sacrifiedItemsMap.clear()
itemsSacrifice = 0
}

override fun getDescription(timesGained: Long): List<String> {
val percentage = timesGained.toDouble() / itemsSacrifice
val dropRate = LorenzUtils.formatPercentage(percentage.coerceAtMost(1.0))
return listOf(
"§7Dropped §e${timesGained.addSeparators()} §7times.",
"§7Your drop rate: §c$dropRate.",
)
}

override fun getCoinName(item: TrackedItem) = "§dDragon Essence"

override fun getCoinDescription(item: TrackedItem): List<String> {
val essences = NumberUtil.format(item.totalAmount)
superhize marked this conversation as resolved.
Show resolved Hide resolved
return listOf(
"§7Sacrificed items give you dragon essence.",
"§7You got §6$essences essence §7that way.",
)
}

@Expose
var itemsSacrifice = 0L
superhize marked this conversation as resolved.
Show resolved Hide resolved

@Expose
var sacrifiedItemsMap: MutableMap<String, Long> = mutableMapOf()
superhize marked this conversation as resolved.
Show resolved Hide resolved
}

private fun drawDisplay(data: Data): List<Searchable> = buildList {
addSearchString("§5§lDraconic Sacrifice Profit Tracker")
val profit = tracker.drawItems(data, { true }, this)

add(
Renderable.hoverTips(
"§b${data.itemsSacrifice.addSeparators()} §6Items Sacrified",
data.sacrifiedItemsMap.map { (key, value) -> "$key: §b$value" },
).toSearchable()
)

add(tracker.addTotalProfit(profit, data.itemsSacrifice, "sacrifice"))

tracker.addPriceFromButton(this)
}

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
sacrificeLoot.matchMatcher(event.message) {
val amount = group("amount").toInt()
val item = group("item")
tracker.addItem("ESSENCE_DRAGON".asInternalName(), amount, command = false)
superhize marked this conversation as resolved.
Show resolved Hide resolved
tracker.modify {
it.itemsSacrifice += 1
it.sacrifiedItemsMap.addOrPut(item, 1)
}
}

bonusLoot.matchMatcher(event.message) {
val item = group("item")
val amount = groupOrNull("amount")?.toInt() ?: 1
val internalName = NEUInternalName.fromItemNameOrNull(item) ?: return
tracker.addItem(internalName, amount, command = false)
}
tracker.update()
}

@SubscribeEvent
fun onRender(event: GuiRenderEvent) {
if (!isEnabled()) return
if (config.onlyInVoidSlate && !altarArea.isPlayerInside()) return

tracker.renderDisplay(config.position)
}

fun resetCommand() {
tracker.resetCommand()
}

private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
}
Loading