From 99ad5e33b9732b1e9bc4fc3cd9cd7637dbc494aa Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 23 Aug 2023 11:54:11 +0200 Subject: Anita Extra Farming Fortune --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 + .../skyhanni/config/features/GardenConfig.java | 12 +++- .../garden/inventory/AnitaExtraFarmingFortune.kt | 73 ++++++++++++++++++++++ .../utils/jsonobjects/AnitaUpgradeCostsJson.java | 17 +++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 3977b52b8..cee9dafbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -293,6 +293,7 @@ class SkyHanniMod { loadModule(GardenVisitorColorNames()) loadModule(TeleportPadCompactName()) loadModule(AnitaMedalProfit()) + loadModule(AnitaExtraFarmingFortune()) loadModule(ComposterDisplay()) loadModule(GardenComposterInventoryFeatures()) loadModule(MinionCollectLogic()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java index 36d2fbb50..82a3c9516 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -984,13 +984,13 @@ public class GardenConfig { public Position farmingArmorDropsPos = new Position(16, -232, false, true); @Expose - @ConfigOption(name = "Anita Medal Profit", desc = "") + @ConfigOption(name = "Anita Shop", desc = "") @ConfigEditorAccordion(id = 16) public boolean anitaMedalProfit = false; @Expose @ConfigOption( - name = "Show Prices", + name = "Medal Prices", desc = "Helps to identify profitable items to buy at the Anita item shop " + "and potential profit from selling the item at the auction house." ) @@ -998,6 +998,14 @@ public class GardenConfig { @ConfigAccordionId(id = 16) public boolean anitaMedalProfitEnabled = true; + @Expose + @ConfigOption( + name = "Extra Farming Fortune", + desc = "Show Amount of upgrades and cost to max out in the item tooltip.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 16) + public boolean extraFarmingFortune = true; + @Expose public Position anitaMedalProfitPos = new Position(206, 158, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt new file mode 100644 index 000000000..c64710755 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt @@ -0,0 +1,73 @@ +package at.hannibal2.skyhanni.features.garden.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.indexOfFirst +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPrice +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.jsonobjects.AnitaUpgradeCostsJson +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class AnitaExtraFarmingFortune { + private val config get() = SkyHanniMod.feature.garden + private var levelPrice = emptyMap() + + @SubscribeEvent + fun onItemTooltipLow(event: ItemTooltipEvent) { + if (!config.extraFarmingFortune) return + + if (InventoryUtils.openInventoryName() != "Anita") return + + val stack = event.itemStack ?: return + + if (!stack.displayName.contains("Extra Farming Fortune")) return + + val anitaUpgrade = GardenAPI.config?.fortune?.anitaUpgrade ?: return + + // TODO: Add support for 5% or 10% contribution bonus +// val currentPrice = levelPrice[anitaUpgrade + 1] ?: return + + var goldMedals = 0 + var jacobTickets = 0 + for ((level, price) in levelPrice) { + if (level > anitaUpgrade) { + goldMedals += price.gold_medals + jacobTickets += price.jacob_tickets + } + } + + val index = event.toolTip.indexOfFirst("§5§o§eClick to trade!")?.let { it - 1 } ?: return + + // TODO: maybe only show the price when playing classic +// if (!LorenzUtils.noTradeMode) { + val price = jacobTickets * "JACOBS_TICKET".asInternalName().getPrice() + event.toolTip.add(index, " §7Price: §6${NumberUtil.format(price)} coins") +// } + event.toolTip.add(index, "§aJacob Tickets §8x${jacobTickets.addSeparators()}") + event.toolTip.add(index, "§6Gold medals: §8x$goldMedals") + event.toolTip.add(index, "§7Cost to max out") + event.toolTip.add(index, "") + + + val upgradeIndex = event.toolTip.indexOfFirst { it.contains("You have") } + if (upgradeIndex != -1) { + event.toolTip.add(upgradeIndex + 1, "§7Upgrades: §e$anitaUpgrade/${levelPrice.size}") + } + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + event.getConstant("AnitaUpgradeCosts")?.let { + val map = mutableMapOf() + for ((rawNumber, price) in it.level_price) { + map[rawNumber.toInt()] = price + } + levelPrice = map + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java new file mode 100644 index 000000000..c0fbd0ad0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java @@ -0,0 +1,17 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.Map; + +public class AnitaUpgradeCostsJson { + @Expose + public Map level_price; + + public static class Price { + @Expose + public Integer gold_medals; + @Expose + public Integer jacob_tickets; + } +} -- cgit