From 1e38bdc596e99830c1f04a5aef75db2b7e6a8caa Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 17 Jun 2023 22:38:50 +1000 Subject: v2 for fortune guide (#188) --- .../java/at/hannibal2/skyhanni/config/Storage.java | 6 + .../java/at/hannibal2/skyhanni/data/ChatManager.kt | 5 +- .../skyhanni/features/garden/CropAccessory.kt | 10 +- .../garden/fortuneguide/CaptureFarmingGear.kt | 34 +- .../features/garden/fortuneguide/FFGuideGUI.kt | 370 +++++++++++++-------- .../features/garden/fortuneguide/FFStats.kt | 161 +++++---- .../features/garden/fortuneguide/FFTypes.kt | 3 +- .../garden/fortuneguide/FarmingReforges.kt | 31 ++ .../features/garden/fortuneguide/FarmingSets.kt | 15 + .../features/garden/fortuneguide/FortuneStats.kt | 19 ++ .../features/garden/fortuneguide/FortuneUpgrade.kt | 11 + .../garden/fortuneguide/FortuneUpgrades.kt | 233 +++++++++++++ .../features/garden/fortuneguide/TODO list | 54 ++- .../garden/fortuneguide/pages/CactusPage.kt | 61 ---- .../features/garden/fortuneguide/pages/CanePage.kt | 74 ----- .../garden/fortuneguide/pages/CarrotPage.kt | 76 ----- .../garden/fortuneguide/pages/CocoaPage.kt | 64 ---- .../features/garden/fortuneguide/pages/CropPage.kt | 40 +++ .../garden/fortuneguide/pages/MelonPage.kt | 66 ---- .../garden/fortuneguide/pages/MushroomPage.kt | 72 ---- .../garden/fortuneguide/pages/OverviewPage.kt | 345 ++++++++++--------- .../garden/fortuneguide/pages/PotatoPage.kt | 74 ----- .../garden/fortuneguide/pages/PumpkinPage.kt | 66 ---- .../garden/fortuneguide/pages/UpgradePage.kt | 78 +++++ .../features/garden/fortuneguide/pages/WartPage.kt | 74 ----- .../garden/fortuneguide/pages/WheatPage.kt | 74 ----- .../at/hannibal2/skyhanni/utils/GuiRenderUtils.kt | 47 ++- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 16 + 28 files changed, 1071 insertions(+), 1108 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingSets.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CactusPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CanePage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CarrotPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CocoaPage.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/MelonPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/MushroomPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/PotatoPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/PumpkinPage.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/WartPage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/WheatPage.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 68726aa34..f853d4a8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -126,6 +126,9 @@ public class Storage { @Expose public String composterCurrentFuelItem = ""; + @Expose + public int uniqueVisitors = 0; + @Expose public VisitorDrops visitorDrops = new VisitorDrops(); @@ -171,6 +174,9 @@ public class Storage { public static class Fortune { + @Expose + public Map outdatedItems = new HashMap<>(); + @Expose public int anitaUpgrade = -1; diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index a21b9e133..643ef46ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -85,18 +85,15 @@ class ChatManager { val last = lines.last() if (last.startsWith("§f§lCOMMON")) return true - if (last.startsWith("§f§lCOMMON")) return true if (last.startsWith("§a§lUNCOMMON")) return true if (last.startsWith("§9§lRARE")) return true if (last.startsWith("§5§lEPIC")) return true if (last.startsWith("§6§lLEGENDARY")) return true + if (last.startsWith("§d§lMYTHIC")) return true if (last.startsWith("§c§lSPECIAL")) return true // TODO confirm this format is correct if (last.startsWith("§c§lVERY SPECIAL")) return true - - if (last.startsWith("§d§lMYTHIC")) return true - return false } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt index 441453ded..b895c6511 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt @@ -1,14 +1,14 @@ package at.hannibal2.skyhanni.features.garden -enum class CropAccessory(val internalName: String, private val affectedCrops: Set, private val fortune: Double) { - NONE("NONE", emptySet(), 0.0), - CROPIE("CROPIE_TALISMAN", setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT), 10.0), +enum class CropAccessory(val internalName: String, private val affectedCrops: Set, private val fortune: Double, val upgradeCost: Pair?) { + NONE("NONE", emptySet(), 0.0, null), + CROPIE("CROPIE_TALISMAN", setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT), 10.0, Pair("CROPIE", 256)), SQUASH( "SQUASH_RING", setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT, CropType.COCOA_BEANS, CropType.MELON, CropType.PUMPKIN), - 20.0 + 20.0, Pair("SQUASH", 128) ), - FERMENTO("FERMENTO_ARTIFACT", CropType.values().toSet(), 30.0), + FERMENTO("FERMENTO_ARTIFACT", CropType.values().toSet(), 30.0, Pair("CONDENSED_FERMENTO", 8)), ; fun getFortune(cropType: CropType): Double { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 47d44e5c1..2da6f89b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.utils.InventoryUtils @@ -12,20 +13,25 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.math.round class CaptureFarmingGear { private val farmingItems get() = GardenAPI.config?.fortune?.farmingItems + private val outdatedItems get() = GardenAPI.config?.fortune?.outdatedItems private val farmingLevelUpPattern = "SKILL LEVEL UP Farming .*➜(?.*)".toPattern() private val fortuneUpgradePattern = "You claimed the Garden Farming Fortune (?.*) upgrade!".toPattern() private val anitaBuffPattern = "You tiered up the Extra Farming Drops upgrade to [+](?.*)%!".toPattern() private val anitaMenuPattern = "You have: [+](?.*)%".toPattern() + private val lotusUpgradePattern = "Lotus (?.*) upgraded to [+].*☘!".toPattern() + private val petLevelUpPattern = "Your (?.*) leveled up to level .*!".toPattern() companion object { private val strengthPattern = " Strength: §r§c❁(?.*)".toPattern() @@ -45,7 +51,7 @@ class CaptureFarmingGear { val currentCrop = itemStack.getCropType() if (currentCrop == null) { - //todo generic tool as fallback item + //todo better fall back items //todo Daedalus axe } else { for (item in FarmingItems.values()) { @@ -83,6 +89,7 @@ class CaptureFarmingGear { if (!LorenzUtils.inSkyBlock) return val hidden = GardenAPI.config?.fortune ?: return val farmingItems = farmingItems ?: return + val outdatedItems = outdatedItems ?: return if (event.inventoryName == "Your Equipment and Stats") { for ((_, slot) in event.inventoryItems) { val split = slot.getInternalName().split("_") @@ -90,8 +97,13 @@ class CaptureFarmingGear { for (item in FarmingItems.values()) { if (item.name == split.last()) { farmingItems[item] = slot + outdatedItems[item] = false } } + FarmingFortuneDisplay.loadFortuneLineData(slot, 0.0) + val enchantments = slot.getEnchantments() ?: emptyMap() + val greenThumbLvl = (enchantments["green_thumb"] ?: continue) + GardenAPI.config?.uniqueVisitors = round(FarmingFortuneDisplay.greenThumbFortune / (greenThumbLvl * 0.05)).toInt() } } } @@ -109,18 +121,21 @@ class CaptureFarmingGear { if (split.first() == "ELEPHANT") { if (split.last().toInt() > highestElephantLvl) { farmingItems[FarmingItems.ELEPHANT] = item + outdatedItems[FarmingItems.ELEPHANT] = false highestElephantLvl = split.last().toInt() } } if (split.first() == "MOOSHROOM_COW") { if (split.last().toInt() > highestMooshroomLvl) { farmingItems[FarmingItems.MOOSHROOM_COW] = item + outdatedItems[FarmingItems.MOOSHROOM_COW] = false highestMooshroomLvl = split.last().toInt() } } if (split.first() == "RABBIT") { if (split.last().toInt() > highestRabbitLvl) { farmingItems[FarmingItems.RABBIT] = item + outdatedItems[FarmingItems.RABBIT] = false highestRabbitLvl = split.last().toInt() } } @@ -181,6 +196,7 @@ class CaptureFarmingGear { fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return val hidden = GardenAPI.config?.fortune ?: return + val outdatedItems = outdatedItems ?: return val msg = event.message.removeColor().trim() fortuneUpgradePattern.matchMatcher(msg) { ProfileStorageData.playerSpecific?.gardenCommunityUpgrade = group("level").romanToDecimal() @@ -191,6 +207,22 @@ class CaptureFarmingGear { anitaBuffPattern.matchMatcher(msg) { hidden.anitaUpgrade = group("level").toInt() / 2 } + lotusUpgradePattern.matchMatcher(msg) { + val piece = group("piece").uppercase() + for (item in FarmingItems.values()) { + if (item.name == piece) { + outdatedItems[item] = true + } + } + } + petLevelUpPattern.matchMatcher(msg) { + val pet = group("pet").uppercase() + for (item in FarmingItems.values()) { + if (item.name.contains(pet)) { + outdatedItems[item] = true + } + } + } if (msg == "Yum! You gain +5☘ Farming Fortune for 48 hours!") { hidden.cakeExpiring = System.currentTimeMillis() + 172800000 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index 25636ae8f..874526ac8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -9,6 +9,7 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Blocks +import net.minecraft.init.Items import net.minecraft.item.ItemStack import org.lwjgl.input.Mouse import java.io.IOException @@ -26,20 +27,22 @@ open class FFGuideGUI : GuiScreen() { const val sizeY = 180 var selectedPage = FortuneGuidePage.OVERVIEW - var breakdownMode = true - var currentPet = 0 + var currentCrop: CropType? = null + //todo set this to what they have equip + var currentPet = FarmingItems.ELEPHANT var currentArmor = 0 var currentEquipment = 0 var mouseX = 0 var mouseY = 0 + var lastMouseScroll = 0 + var noMouseScrollFrames = 0 + var lastClickedHeight = 0 var tooltipToDisplay = mutableListOf() fun isInGui() = Minecraft.getMinecraft().currentScreen is FFGuideGUI - var cakeBuffTime = -1L - fun FarmingItems.getItem(): ItemStack { val fortune = GardenAPI.config?.fortune ?: return getFallbackItem(this) @@ -57,20 +60,18 @@ open class FFGuideGUI : GuiScreen() { init { FFStats.loadFFData() + FortuneUpgrades.generateGenericUpgrades() + pages[FortuneGuidePage.OVERVIEW] = OverviewPage() - pages[FortuneGuidePage.WHEAT] = WheatPage() - pages[FortuneGuidePage.CARROT] = CarrotPage() - pages[FortuneGuidePage.POTATO] = PotatoPage() - pages[FortuneGuidePage.PUMPKIN] = PumpkinPage() - pages[FortuneGuidePage.SUGAR_CANE] = CanePage() - pages[FortuneGuidePage.MELON] = MelonPage() - pages[FortuneGuidePage.CACTUS] = CactusPage() - pages[FortuneGuidePage.COCOA_BEANS] = CocoaPage() - pages[FortuneGuidePage.MUSHROOM] = MushroomPage() - pages[FortuneGuidePage.NETHER_WART] = WartPage() - - GardenAPI.config?.fortune?.let { - cakeBuffTime = it.cakeExpiring + pages[FortuneGuidePage.CROP] = CropPage() + pages[FortuneGuidePage.UPGRADES] = UpgradePage() + + if (currentCrop != null) { + for (item in FarmingItems.values()) { + if (item.name == currentCrop?.name) { + FFStats.getCropStats(currentCrop!!, item.getItem()) + } + } } } @@ -88,40 +89,11 @@ open class FFGuideGUI : GuiScreen() { drawRect(guiLeft, guiTop, guiLeft + sizeX, guiTop + sizeY, 0x50000000) renderTabs() - if (breakdownMode) { - if (selectedPage != FortuneGuidePage.OVERVIEW) { - GuiRenderUtils.renderItemAndTip( - FarmingItems.ELEPHANT.getItem(), guiLeft + 152, guiTop + 160, mouseX, mouseY, - if (currentPet == 0) 0xFF00FF00.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - FarmingItems.MOOSHROOM_COW.getItem(), guiLeft + 172, guiTop + 160, mouseX, mouseY, - if (currentPet == 1) 0xFF00FF00.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - FarmingItems.RABBIT.getItem(), guiLeft + 192, guiTop + 160, mouseX, mouseY, - if (currentPet == 2) 0xFF00FF00.toInt() else 0xFF43464B.toInt() - ) - - GuiRenderUtils.renderItemAndTip( - FarmingItems.HELMET.getItem(), guiLeft + 162, guiTop + 80, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.CHESTPLATE.getItem(), guiLeft + 162, guiTop + 100, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.LEGGINGS.getItem(), guiLeft + 162, guiTop + 120, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.BOOTS.getItem(), guiLeft + 162, guiTop + 140, mouseX, mouseY) - - GuiRenderUtils.renderItemAndTip( - FarmingItems.NECKLACE.getItem(), guiLeft + 182, guiTop + 80, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.CLOAK.getItem(), guiLeft + 182, guiTop + 100, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.BELT.getItem(), guiLeft + 182, guiTop + 120, mouseX, mouseY) - GuiRenderUtils.renderItemAndTip( - FarmingItems.BRACELET.getItem(), guiLeft + 182, guiTop + 140, mouseX, mouseY) - - } else { + if (selectedPage == FortuneGuidePage.UPGRADES) { + // + } else { + GuiRenderUtils.drawStringCentered("§7SkyHanni", guiLeft + 325, guiTop + 170) + if (currentCrop == null) { GuiRenderUtils.renderItemAndTip( FarmingItems.HELMET.getItem(), guiLeft + 142, guiTop + 5, mouseX, mouseY, if (currentArmor == 1) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() @@ -158,20 +130,50 @@ open class FFGuideGUI : GuiScreen() { GuiRenderUtils.renderItemAndTip( FarmingItems.ELEPHANT.getItem(), guiLeft + 152, guiTop + 130, mouseX, mouseY, - if (currentPet == 0) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + if (currentPet == FarmingItems.ELEPHANT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() ) GuiRenderUtils.renderItemAndTip( FarmingItems.MOOSHROOM_COW.getItem(), guiLeft + 172, guiTop + 130, mouseX, mouseY, - if (currentPet == 1) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + if (currentPet == FarmingItems.MOOSHROOM_COW) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() ) GuiRenderUtils.renderItemAndTip( FarmingItems.RABBIT.getItem(), guiLeft + 192, guiTop + 130, mouseX, mouseY, - if (currentPet == 2) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + if (currentPet == FarmingItems.RABBIT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + ) + } else { + GuiRenderUtils.renderItemAndTip( + FarmingItems.ELEPHANT.getItem(), guiLeft + 152, guiTop + 160, mouseX, mouseY, + if (currentPet == FarmingItems.ELEPHANT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + ) + GuiRenderUtils.renderItemAndTip( + FarmingItems.MOOSHROOM_COW.getItem(), guiLeft + 172, guiTop + 160, mouseX, mouseY, + if (currentPet == FarmingItems.MOOSHROOM_COW) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + ) + GuiRenderUtils.renderItemAndTip( + FarmingItems.RABBIT.getItem(), guiLeft + 192, guiTop + 160, mouseX, mouseY, + if (currentPet == FarmingItems.RABBIT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() ) + + GuiRenderUtils.renderItemAndTip( + FarmingItems.HELMET.getItem(), guiLeft + 162, guiTop + 80, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.CHESTPLATE.getItem(), guiLeft + 162, guiTop + 100, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.LEGGINGS.getItem(), guiLeft + 162, guiTop + 120, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.BOOTS.getItem(), guiLeft + 162, guiTop + 140, mouseX, mouseY) + + GuiRenderUtils.renderItemAndTip( + FarmingItems.NECKLACE.getItem(), guiLeft + 182, guiTop + 80, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.CLOAK.getItem(), guiLeft + 182, guiTop + 100, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.BELT.getItem(), guiLeft + 182, guiTop + 120, mouseX, mouseY) + GuiRenderUtils.renderItemAndTip( + FarmingItems.BRACELET.getItem(), guiLeft + 182, guiTop + 140, mouseX, mouseY) } } - GuiRenderUtils.drawStringCentered("§7SkyHanni", guiLeft + 325, guiTop + 170) GuiRenderUtils.drawStringCentered("§cIn beta! Report issues and suggestions on the discord", guiLeft + sizeX / 2, guiTop + sizeY + 10) pages[selectedPage]?.drawPage(mouseX, mouseY, partialTicks) @@ -184,116 +186,202 @@ open class FFGuideGUI : GuiScreen() { } } - @Throws(IOException::class) - override fun mouseClicked(originalX: Int, originalY: Int, mouseButton: Int) { - super.mouseClicked(originalX, originalY, mouseButton) + override fun handleMouseInput() { + super.handleMouseInput() - for (page in FortuneGuidePage.values()) { - val x = guiLeft + (page.ordinal) * 30 + 15 - val y = guiTop - 28 + if (Mouse.getEventButtonState()) { + mouseClickEvent() + } + if (!Mouse.getEventButtonState()) { + if (Mouse.getEventDWheel() != 0) { + lastMouseScroll = Mouse.getEventDWheel() + noMouseScrollFrames = 0 + } + } + } - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { - if (selectedPage != page) { - SoundUtils.playClickSound() - selectedPage = page + @Throws(IOException::class) + fun mouseClickEvent() { + var x = guiLeft + 15 + var y = guiTop - 28 + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + SoundUtils.playClickSound() + if (currentCrop != null) { + currentCrop = null + if (selectedPage != FortuneGuidePage.UPGRADES) { + selectedPage = FortuneGuidePage.OVERVIEW + } + } else { + if (selectedPage == FortuneGuidePage.UPGRADES) { + selectedPage = FortuneGuidePage.OVERVIEW + } else { + selectedPage = FortuneGuidePage.UPGRADES } } } - if (selectedPage == FortuneGuidePage.OVERVIEW) { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 152, guiTop + 130, 16, 16) && currentPet != 0) { - SoundUtils.playClickSound() - currentPet = 0 - FFStats.totalFF(FFStats.elephantFF) - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 172, guiTop + 130, 16, 16) && currentPet != 1 - ) { - SoundUtils.playClickSound() - currentPet = 1 - FFStats.totalFF(FFStats.mooshroomFF) - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 192, guiTop + 130, 16, 16) && currentPet != 2 - ) { - SoundUtils.playClickSound() - currentPet = 2 - FFStats.totalFF(FFStats.rabbitFF) - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 1) 0 else 1 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 2) 0 else 2 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 3) 0 else 3 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 4) 0 else 4 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 262, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 1) 0 else 1 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 282, guiTop + 5, 16, 16)) { + for (crop in CropType.values()) { + x += 30 + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 2) 0 else 2 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 302, guiTop + 5, 16, 16)) { + if (currentCrop != crop) { + currentCrop = crop + if (selectedPage == FortuneGuidePage.OVERVIEW) { + selectedPage = FortuneGuidePage.CROP + } + for (item in FarmingItems.values()) { + if (item.name == crop.name) { + FFStats.getCropStats(crop, item.getItem()) + FortuneUpgrades.getCropSpecific(item.getItem()) + } + } + } else { + if (selectedPage == FortuneGuidePage.CROP) { + selectedPage = FortuneGuidePage.UPGRADES + for (item in FarmingItems.values()) { + if (item.name == crop.name) { + FortuneUpgrades.getCropSpecific(item.getItem()) + } + } + } else { + selectedPage = FortuneGuidePage.CROP + for (item in FarmingItems.values()) { + if (item.name == crop.name) { + FFStats.getCropStats(crop, item.getItem()) + } + } + } + } + } + } + + x = guiLeft - 28 + y = guiTop + 15 + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + if (selectedPage != FortuneGuidePage.CROP && selectedPage != FortuneGuidePage.OVERVIEW) { SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 3) 0 else 3 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 322, guiTop + 5, 16, 16)) { + selectedPage = if (currentCrop == null) { + FortuneGuidePage.OVERVIEW + } else { + FortuneGuidePage.CROP + } + } + } + y += 30 + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + if (selectedPage != FortuneGuidePage.UPGRADES) { + selectedPage = FortuneGuidePage.UPGRADES SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 4) 0 else 4 } + } + if (selectedPage != FortuneGuidePage.UPGRADES) { + if (currentCrop == null) { + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 152, guiTop + 130, + 16, 16) && currentPet != FarmingItems.ELEPHANT) { + SoundUtils.playClickSound() + currentPet = FarmingItems.ELEPHANT + FFStats.getTotalFF() + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 172, guiTop + 130, + 16, 16) && currentPet != FarmingItems.MOOSHROOM_COW) { + SoundUtils.playClickSound() + currentPet = FarmingItems.MOOSHROOM_COW + FFStats.getTotalFF() + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 192, guiTop + 130, + 16, 16) && currentPet != FarmingItems.RABBIT) { + SoundUtils.playClickSound() + currentPet = FarmingItems.RABBIT + FFStats.getTotalFF() + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 1) 0 else 1 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 2) 0 else 2 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 3) 0 else 3 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 4) 0 else 4 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 262, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 1) 0 else 1 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 282, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 2) 0 else 2 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 302, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 3) 0 else 3 + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 322, guiTop + 5, 16, 16)) { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 4) 0 else 4 + } + } else { + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 152, guiTop + 160, + 16, 16) && currentPet != FarmingItems.ELEPHANT) { + SoundUtils.playClickSound() + currentPet = FarmingItems.ELEPHANT + FFStats.getTotalFF() + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 172, guiTop + 160, + 16, 16) && currentPet != FarmingItems.MOOSHROOM_COW) { + SoundUtils.playClickSound() + currentPet = FarmingItems.MOOSHROOM_COW + FFStats.getTotalFF() + } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 192, guiTop + 160, + 16, 16) && currentPet != FarmingItems.RABBIT) { + SoundUtils.playClickSound() + currentPet = FarmingItems.RABBIT + FFStats.getTotalFF() + } + } } else { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 152, guiTop + 160, 16, 16) && currentPet != 0) { - SoundUtils.playClickSound() - currentPet = 0 - FFStats.totalFF(FFStats.elephantFF) - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 172, guiTop + 160, 16, 16) && currentPet != 1 - ) { - SoundUtils.playClickSound() - currentPet = 1 - FFStats.totalFF(FFStats.mooshroomFF) - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 192, guiTop + 160, 16, 16) && currentPet != 2 - ) { - SoundUtils.playClickSound() - currentPet = 2 - FFStats.totalFF(FFStats.rabbitFF) + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft, guiTop, sizeX, sizeY)) { + lastClickedHeight = mouseY } } } private fun renderTabs() { - for (page in FortuneGuidePage.values()) { - val x = guiLeft + (page.ordinal) * 30 + 15 - val y = guiTop - 28 - drawRect(x, y, x + 25, y + 28, if (page == selectedPage) 0x50555555 else 0x50000000) - - if (page.crop != null) { - GuiRenderUtils.renderItemStack(page.crop.icon, x + 5, y + 5) - } else GuiRenderUtils.renderItemStack(ItemStack(Blocks.grass), x + 5, y + 5) + var x = guiLeft + 15 + var y = guiTop - 28 + drawRect(x, y, x + 25, y + 28, if (currentCrop == null) 0x50555555 else 0x50000000) + GuiRenderUtils.renderItemStack(ItemStack(Blocks.grass), x + 5, y + 5) + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + tooltipToDisplay.add("§eOverview") + } - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 25)) { - tooltipToDisplay.add(page.pageName) + for (crop in CropType.values()) { + x += 30 + drawRect(x, y, x + 25, y + 28, if (currentCrop == crop) 0x50555555 else 0x50000000) + GuiRenderUtils.renderItemStack(crop.icon, x + 5, y + 5) + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + tooltipToDisplay.add("§e${crop.cropName}") } } + + x = guiLeft - 28 + y = guiTop + 15 + + drawRect(x, y, x + 28, y + 25, if (selectedPage != FortuneGuidePage.UPGRADES) 0x50555555 else 0x50000000) + GuiRenderUtils.renderItemStack(ItemStack(Items.gold_ingot), x + 5, y + 5) + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + tooltipToDisplay.add("§eBreakdown") + } + y += 30 + drawRect(x, y, x + 28, y + 25, if (selectedPage == FortuneGuidePage.UPGRADES) 0x50555555 else 0x50000000) + GuiRenderUtils.renderItemStack(ItemStack(Items.map), x + 5, y + 5) + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + tooltipToDisplay.add("§eUpgrades") + } } - enum class FortuneGuidePage(val crop: CropType?) { - OVERVIEW(null), - WHEAT(CropType.WHEAT), - CARROT(CropType.CARROT), - POTATO(CropType.POTATO), - NETHER_WART(CropType.NETHER_WART), - PUMPKIN(CropType.PUMPKIN), - MELON(CropType.MELON), - COCOA_BEANS(CropType.COCOA_BEANS), - SUGAR_CANE(CropType.SUGAR_CANE), - CACTUS(CropType.CACTUS), - MUSHROOM(CropType.MUSHROOM), - ; - - val pageName = crop?.let { "§e" + crop.cropName } ?: "§eOverview" + enum class FortuneGuidePage { + OVERVIEW, + CROP, + UPGRADES } abstract class FFGuidePage { abstract fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) } } - diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index 1d5638061..26a649aa1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -3,9 +3,9 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide import at.hannibal2.skyhanni.data.CropAccessoryData import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount @@ -14,7 +14,16 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel import net.minecraft.item.ItemStack object FFStats { + private val toolHasBountiful get() = GardenAPI.config?.toolWithBountiful + + private val mathCrops = listOf(CropType.WHEAT, CropType.CARROT, CropType.POTATO, CropType.SUGAR_CANE, CropType.NETHER_WART) + private val dicerCrops = listOf(CropType.PUMPKIN, CropType.MELON) + private val farmingBoots = arrayListOf("RANCHERS_BOOTS", "FARMER_BOOTS") + + var cakeExpireTime = 0L + + // todo maybe these could be maps val necklaceFF = mutableMapOf() val cloakFF = mutableMapOf() val beltFF = mutableMapOf() @@ -37,18 +46,11 @@ object FFStats { var totalBaseFF = mutableMapOf() - val wheatFF = mutableMapOf() - val carrotFF = mutableMapOf() - val potatoFF = mutableMapOf() - val caneFF = mutableMapOf() - val wartFF = mutableMapOf() - val pumpkinFF = mutableMapOf() - val melonFF = mutableMapOf() - val mushroomFF = mutableMapOf() - val cocoaFF = mutableMapOf() - val cactusFF = mutableMapOf() + val cropPage = mutableMapOf>() fun loadFFData() { + cakeExpireTime = GardenAPI.config?.fortune?.cakeExpiring ?: -1L + getEquipmentFFData(FarmingItems.NECKLACE.getItem(), necklaceFF) getEquipmentFFData(FarmingItems.CLOAK.getItem(), cloakFF) getEquipmentFFData(FarmingItems.BELT.getItem(), beltFF) @@ -76,23 +78,77 @@ object FFStats { getPetFFData(FarmingItems.RABBIT.getItem(), rabbitFF) getGenericFF(baseFF) - getToolFF(FarmingItems.WHEAT.getItem(), wheatFF) - getToolFF(FarmingItems.CARROT.getItem(), carrotFF) - getToolFF(FarmingItems.POTATO.getItem(), potatoFF) - getToolFF(FarmingItems.SUGAR_CANE.getItem(), caneFF) - getToolFF(FarmingItems.NETHER_WART.getItem(), wartFF) - getToolFF(FarmingItems.PUMPKIN.getItem(), pumpkinFF) - getToolFF(FarmingItems.MELON.getItem(), melonFF) - getToolFF(FarmingItems.MUSHROOM.getItem(), mushroomFF) - getToolFF(FarmingItems.COCOA_BEANS.getItem(), cocoaFF) - getToolFF(FarmingItems.CACTUS.getItem(), cactusFF) - - currentPetItem = FarmingItems.ELEPHANT.getItem().getPetItem().toString() - when (FFGuideGUI.currentPet) { - 0 -> totalFF(elephantFF) - 1 -> totalFF(mooshroomFF) - 2 -> totalFF(rabbitFF) + getTotalFF() + } + + fun getCropStats(crop: CropType, tool: ItemStack) { + cropPage.clear() + cropPage[FortuneStats.BASE] = Pair(totalBaseFF[FFTypes.TOTAL] ?: 100.0, 1250.0) + cropPage[FortuneStats.CROP_UPGRADE] = Pair((crop.getUpgradeLevel()?.toDouble() ?: 0.0) * 5.0, 45.0) + cropPage[FortuneStats.ACCESSORY] = Pair(CropAccessoryData.cropAccessory?.getFortune(crop) ?: 0.0, 30.0) + cropPage[FortuneStats.FFD] = Pair((tool.getFarmingForDummiesCount() ?: 0).toDouble(), 5.0) + cropPage[FortuneStats.TURBO] = Pair(FarmingFortuneDisplay.getTurboCropFortune(tool, crop), 25.0) + cropPage[FortuneStats.DEDICATION] = Pair(FarmingFortuneDisplay.getDedicationFortune(tool, crop), 92.0) + cropPage[FortuneStats.CULTIVATING] = Pair(FarmingFortuneDisplay.getCultivatingFortune(tool), 10.0) + + FarmingFortuneDisplay.loadFortuneLineData(tool, 0.0) + + when (crop) { + in mathCrops -> { + cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 50.0) + cropPage[FortuneStats.COUNTER] = Pair(FarmingFortuneDisplay.getCounterFortune(tool), 96.0) + cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + cropPage[FortuneStats.COLLECTION] = Pair(FarmingFortuneDisplay.getCollectionFortune(tool), 48.0) + if (toolHasBountiful?.get(crop) == true) { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 10.0) + } else { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 20.0) + } + } + in dicerCrops -> { + cropPage[FortuneStats.SUNDER] = Pair(FarmingFortuneDisplay.getSunderFortune(tool), 62.5) + if (toolHasBountiful?.get(crop) == true) { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 10.0) + } else { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 20.0) + } + } + CropType.MUSHROOM -> { + cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 30.0) + cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + if (toolHasBountiful?.get(crop) == true) { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 5.0) + } else { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 13.0) + } + } + CropType.COCOA_BEANS -> { + cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 20.0) + cropPage[FortuneStats.SUNDER] = Pair(FarmingFortuneDisplay.getSunderFortune(tool), 62.5) + if (toolHasBountiful?.get(crop) == true) { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 7.0) + } else { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 16.0) + } + } + CropType.CACTUS -> { + cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + if (toolHasBountiful?.get(crop) == true) { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 7.0) + } else { + cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 16.0) + } + } + else -> {} + } + + cropPage[FortuneStats.CROP_TOTAL] = Pair( + cropPage.toList().sumOf { it.second.first }, + cropPage.toList().sumOf { it.second.second }) + + if (tool.getInternalName().contains("DICER")){ + cropPage[FortuneStats.DICER] = Pair(33.0, 33.0) } } @@ -136,7 +192,7 @@ object FFStats { out[FFTypes.COMMUNITY_SHOP] = (ProfileStorageData.playerSpecific?.gardenCommunityUpgrade ?: -1).toDouble() * 4 out[FFTypes.PLOTS] = savedStats.plotsUnlocked.toDouble() * 3 out[FFTypes.ANITA] = savedStats.anitaUpgrade.toDouble() * 2 - if (savedStats.cakeExpiring - System.currentTimeMillis() > 0 || savedStats.cakeExpiring == -1L) { + if (cakeExpireTime - System.currentTimeMillis() > 0 || cakeExpireTime == -1L) { out[FFTypes.CAKE] = 5.0 } else { out[FFTypes.CAKE] = 0.0 @@ -144,46 +200,26 @@ object FFStats { out[FFTypes.TOTAL] = out.values.sum() } - private fun getToolFF(tool: ItemStack, out: MutableMap) { - out[FFTypes.TOTAL] = 0.0 - val crop = tool.getCropType() - - val accessoryFortune= crop?.let { - CropAccessoryData.cropAccessory?.getFortune(it) + fun getTotalFF() { + var petList = mutableMapOf() + when (FFGuideGUI.currentPet) { + FarmingItems.ELEPHANT -> { + petList = elephantFF + } + FarmingItems.MOOSHROOM_COW -> { + petList = mooshroomFF + } + FarmingItems.RABBIT -> { + petList = rabbitFF + } + else -> {} } + currentPetItem = FFGuideGUI.currentPet.getItem().getPetItem().toString() - out[FFTypes.CROP_UPGRADE] = (crop?.getUpgradeLevel()?.toDouble() ?: 0.0) * 5.0 - out[FFTypes.ACCESSORY] = accessoryFortune ?: 0.0 - - out[FFTypes.BASE] = FarmingFortuneDisplay.getToolFortune(tool) - out[FFTypes.COUNTER] = FarmingFortuneDisplay.getCounterFortune(tool) - out[FFTypes.COLLECTION] = FarmingFortuneDisplay.getCollectionFortune(tool) - out[FFTypes.TURBO] = FarmingFortuneDisplay.getTurboCropFortune(tool, crop) - out[FFTypes.DEDICATION] = FarmingFortuneDisplay.getDedicationFortune(tool, crop) - out[FFTypes.SUNDER] = FarmingFortuneDisplay.getSunderFortune(tool) - out[FFTypes.HARVESTING] = FarmingFortuneDisplay.getHarvestingFortune(tool) - out[FFTypes.CULTIVATING] = FarmingFortuneDisplay.getCultivatingFortune(tool) - out[FFTypes.FFD] = (tool.getFarmingForDummiesCount() ?: 0).toDouble() - - val enchantmentFortune = out[FFTypes.SUNDER]!! + out[FFTypes.HARVESTING]!! + out[FFTypes.CULTIVATING]!! - - FarmingFortuneDisplay.loadFortuneLineData(tool, enchantmentFortune) - - out[FFTypes.REFORGE] = FarmingFortuneDisplay.reforgeFortune - - out[FFTypes.TOTAL] = out.values.sum() - } - - fun totalFF(petList: MutableMap) { totalBaseFF = (baseFF.toList() + armorTotalFF.toList() + equipmentTotalFF.toList() + petList.toList()).groupBy({ it.first }, { it.second }).map { (key, values) -> key to values.sum() } .toMap() as MutableMap - currentPetItem = when (FFGuideGUI.currentPet) { - 0 -> FarmingItems.ELEPHANT.getItem().getPetItem().toString() - 1 -> FarmingItems.MOOSHROOM_COW.getItem().getPetItem().toString() - else -> FarmingItems.RABBIT.getItem().getPetItem().toString() - } } private fun getPetFF (pet: ItemStack): Double { @@ -193,7 +229,6 @@ object FFStats { return if (pet.getInternalName().contains("ELEPHANT;4")) { 1.8 * petLevel } else if (pet.getInternalName().contains("MOOSHROOM_COW;4")) { - println("doing cow calc: ${(10 + petLevel).toDouble() + strength / (40 - petLevel * .2)}ff") (10 + petLevel).toDouble() + strength / (40 - petLevel * .2) } else if (pet.getInternalName().contains("MOOSHROOM")) { (10 + petLevel).toDouble() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFTypes.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFTypes.kt index b317199ec..02d8debc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFTypes.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFTypes.kt @@ -2,6 +2,5 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide enum class FFTypes { TOTAL, BASE, REFORGE, ABILITY, GREEN_THUMB, BASE_FF, ANITA, FARMING_LVL, COMMUNITY_SHOP, PLOTS, - CAKE, PET_ITEM, COUNTER, COLLECTION, TURBO, DEDICATION, SUNDER, HARVESTING, CULTIVATING, FFD, - CROP_UPGRADE, ACCESSORY + CAKE, PET_ITEM } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt new file mode 100644 index 000000000..6920c5e77 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +enum class FarmingReforges( + val reforgeName: String, + val reforgeItem: String, + val common: Int, + val uncommon: Int, + val rare: Int, + val epic: Int, + val legendary: Int, + val mythic: Int +) { + BLESSED("Blessed", "BLESSED_FRUIT", 5, 7, 9, 13, 16, 20), + BOUNTIFUL("Bountiful", "GOLDEN_BALL", 1, 2, 3, 5, 7, 10), + BLOOMING("Blooming", "FLOWERING_BOUQUET", 1, 2, 3, 4, 5, 6), + ROOTED("Rooted", "BURROWING_SPORES", 4, 6, 8, 10, 12, 14), + BUSTLING("Bustling", "SKYMART_BROCHURE", 1, 2, 4, 6, 8, 10), + MOSSY("Mossy", "OVERGROWN_GRASS", 5, 10, 15, 20, 25, 30) +} + +operator fun FarmingReforges.get(index: Int, current: Double = 0.0): Double? { + return when (index) { + 0 -> common - current + 1 -> uncommon - current + 2 -> rare - current + 3 -> epic - current + 4 -> legendary - current + 5 -> mythic - current + else -> null + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingSets.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingSets.kt new file mode 100644 index 000000000..fb3c30123 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingSets.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +enum class FarmingSets( + val helmetIncrease: Double, + val chestplateIncrease: Double, + val leggingsIncrease: Double, + val bootsIncrease: Double +) { + MELON(15.0, 20.0, 20.0, 15.0), + CROPIE(15.0, 20.0, 20.0, 15.0), + SQUASH(15.0, 20.0, 20.0, 15.0), + FERMENTO(15.0, 20.0, 20.0, 15.0), + FARMER(0.0, 0.0, 0.0, 0.0), + RANCHERS(0.0, 0.0, 0.0, 0.0) +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt new file mode 100644 index 000000000..8fb09f648 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt @@ -0,0 +1,19 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +enum class FortuneStats(val label: String, val tooltip: String) { + BASE("§2Universal Farming Fortune", "§7§2Farming fortune in that is\n§2applied to every crop\n§eNot the same as tab FF"), + CROP_TOTAL("§6Crop Farming Fortune", "§7§2Farming fortune for this crop"), + ACCESSORY("§2Talisman Bonus", "§7§2Fortune from your talisman\n§2You get 10☘ per talisman tier"), + CROP_UPGRADE("§2Crop Upgrade", "§7§2Fortune from Desk crop upgrades\n§2You get 5☘ per level"), + BASE_TOOL("§2Base tool fortune","§7§2Crop specific fortune from your tool"), + REFORGE("§2Tool reforge", "§7§2Fortune from reforging your tool"), + FFD("§2Farming for Dummies", "§7§2Fortune for each applied book\n§2You get 1☘ per applied book"), + COUNTER("§2Logarithmic Counter", "§7§2Fortune from increasing crop counter\n§2You get 16☘ per digit - 4"), + COLLECTION("§2Collection Analyst", "§7§2Fortune from increasing crop collection\n§2You get 8☘ per digit - 4"), + HARVESTING("§2Harvesting Enchantment", "§7§2Fortune for each enchantment level\n§2You get 12.5☘ per level"), + SUNDER("§2Sunder Enchantment", "§7§2Fortune for each enchantment level\n§2You get 12.5☘ per level"), + CULTIVATING("§2Cultivating Enchantment", "§7§2Fortune for each enchantment level\n§2You get 1☘ per level"), + TURBO("§2Turbo-Crop Enchantment", "§7§2Fortune for each enchantment level\n§2You get 5☘ per level"), + DEDICATION("§2Dedication Enchantment", "§7§2Fortune for each enchantment level\n§2and crop milestone"), + DICER("§2Dicer Ability", "§7§2Theoretical fortune from the dicer ability\n§eIs very random! and not added to total ☘") +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt new file mode 100644 index 000000000..70ce14178 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +data class FortuneUpgrade( + val description: String, + val costCopper: Int?, + val requiredItem: String, + val itemQuantity: Int, + val fortuneIncrease: Double, + var cost: Int? = null, + var costPerFF: Int? = null // also the same as time to repay +) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt new file mode 100644 index 000000000..f6e220fa0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt @@ -0,0 +1,233 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +import at.hannibal2.skyhanni.data.CropAccessoryData +import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter +import at.hannibal2.skyhanni.features.garden.CropAccessory +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop +import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.currentPet +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarity +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NumberUtil.addSuffix +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated +import net.minecraft.item.ItemStack + +object FortuneUpgrades { + private val equipment = listOf(FarmingItems.NECKLACE, FarmingItems.CLOAK, FarmingItems.BELT, FarmingItems.BRACELET) + private val armor = listOf(FarmingItems.HELMET, FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS, FarmingItems.BOOTS) + private val axeCrops = listOf(CropType.MELON, CropType.PUMPKIN, CropType.COCOA_BEANS) + + val genericUpgrades = mutableListOf() + val cropSpecificUpgrades = mutableListOf() + + fun generateGenericUpgrades() { + val hidden = GardenAPI.config?.fortune ?: return + genericUpgrades.clear() + + if (hidden.plotsUnlocked != -1 && hidden.plotsUnlocked != 24) { + genericUpgrades.add(FortuneUpgrade("§7Unlock your ${(hidden.plotsUnlocked + 1).addSuffix()} §7plot", + null, "COMPOST", compostNeeded[hidden.plotsUnlocked], 3.0)) + } + if (hidden.anitaUpgrade != -1 && hidden.anitaUpgrade != 15) { + genericUpgrades.add(FortuneUpgrade("§7Upgrade Anita bonus to level ${hidden.anitaUpgrade + 1}", + null, "JACOBS_TICKET", anitaTicketsNeeded[hidden.anitaUpgrade], 3.0)) + } + + getEquipmentUpgrades() + getPetUpgrades() + getArmorUpgrades() + getTalismanUpgrade() + + genericUpgrades.populateAndSort(0) + } + + //todo fix NEU price data not being loaded if run too early + private fun MutableList.populateAndSort(style: Int) { + this.map { upgrade -> + val cost = (NEUItems.getPrice(upgrade.requiredItem) * (upgrade.itemQuantity)).toInt() + upgrade.cost = cost + upgrade.costPerFF = (cost / upgrade.fortuneIncrease).toInt() + } + when (style) { // sorting later + 0 -> this.sortBy { it.costPerFF } + 1 -> this.sortByDescending { it.costPerFF } + 2 -> this.sortBy { it.cost } + 3 -> this.sortByDescending { it.cost } + 4 -> this.sortBy { it.fortuneIncrease } + 5 -> this.sortByDescending { it.fortuneIncrease } + else -> {} + } + } + + private fun getTalismanUpgrade() { + val currentTalismanTier = CropAccessoryData.cropAccessory?.ordinal ?: return + if (currentTalismanTier < 3) { + val nextTalisman = CropAccessory.values()[currentTalismanTier + 1] + genericUpgrades.add(FortuneUpgrade("§7Upgrade your talisman to ${nextTalisman.internalName.replace("_", " ").lowercase()}", + null, nextTalisman.upgradeCost?.first!!, nextTalisman.upgradeCost.second, 10.0)) + } + } + + private fun getEquipmentUpgrades() { + val visitors = GardenAPI.config?.uniqueVisitors?.toDouble() ?: 0.0 + for (piece in equipment) { + val item = piece.getItem() + //todo tell them to purchase the missing item + if (!item.getInternalName().contains("LOTUS")) return + val enchantments = item.getEnchantments() ?: emptyMap() + val greenThumbLvl = enchantments["green_thumb"] ?: 0 + if (greenThumbLvl != 5 && visitors != 0.0) { + genericUpgrades.add(FortuneUpgrade("§7Enchant your ${item.displayName} §7with Green Thumb ${greenThumbLvl + 1}", + 1500, "GREEN_THUMB;1", getNeededBooks(greenThumbLvl), visitors * 0.05)) + } + recombobulateItem(item, genericUpgrades) + when (item.getReforgeName()) { + "rooted" -> {} + "blooming" -> { + reforgeItem(item, FarmingReforges.ROOTED, genericUpgrades) + } + else -> { + reforgeItem(item, FarmingReforges.BLOOMING, genericUpgrades) + } + } + } + } + //todo adding armor tier upgrades later + + private fun getArmorUpgrades() { + for (piece in armor) { + val item = piece.getItem() + //todo skip if it doesnt exist -> tell them to buy it later + + recombobulateItem(item, genericUpgrades) + when (item.getReforgeName()) { + "mossy" -> {} + "bustling" -> { + reforgeItem(item, FarmingReforges.MOSSY, genericUpgrades) + } + else -> { + reforgeItem(item, FarmingReforges.BUSTLING, genericUpgrades, 100) + } + } + } + } + + //todo needs to be called when switching pets + private fun getPetUpgrades() { + if (currentPet.getItem().getInternalName().contains(";")) { + when (FFStats.currentPetItem) { + "GREEN_BANDANA" -> {} + "YELLOW_BANDANA" -> { + //todo once auction stuff is done + } + else -> { + //give pet yellow bandana + } + } + } + } + + fun getCropSpecific(tool: ItemStack) { + cropSpecificUpgrades.clear() + cropSpecificUpgrades.addAll(genericUpgrades) + // todo tell them to get the tool if it is missing + val crop = tool.getCropType() ?: return + val enchantments = tool.getEnchantments() ?: emptyMap() + val turboCropLvl = enchantments[crop.getTurboCrop()] ?: 0 + val dedicationLvl = enchantments["dedication"] ?: 0 + val cultivatingLvl = enchantments["cultivating"] ?: 0 + val farmingForDummiesCount = tool.getFarmingForDummiesCount() ?: 0 + if (crop in axeCrops) { + val sunderLvl = enchantments["sunder"] ?: 0 + if (sunderLvl != 5) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with Sunder ${sunderLvl + 1}", + 10, "SUNDER;1", getNeededBooks(sunderLvl), 12.5)) + } + } else { + val harvestingLvl = enchantments["harvesting"] ?: 0 + if (harvestingLvl == 5) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with Harvesting ${harvestingLvl + 1}", + 10, "HARVESTING;6", 1, 12.5)) + } + } + if (farmingForDummiesCount != 5) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Add a Farming for Dummies to your ${tool.displayName}", + null, "FARMING_FOR_DUMMIES", 1, 1.0)) + } + val cropMilestone = GardenCropMilestones.getTierForCrops(crop.getCounter()) + if (dedicationLvl != 4 && cropMilestone > 0) { + val dedicationMultiplier = listOf(0.5, 0.75, 1.0, 2.0)[dedicationLvl] + val dedicationIncrease = dedicationMultiplier * cropMilestone - FarmingFortuneDisplay.getDedicationFortune(tool, crop) + if (dedicationLvl == 3) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with Dedication ${dedicationLvl + 1}", + null, "DEDICATION;4", 1, dedicationIncrease)) + } else { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with Dedication ${dedicationLvl + 1}", + 250, "DEDICATION;1", getNeededBooks(dedicationLvl), dedicationIncrease)) + } + } + if (cultivatingLvl == 0) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with Cultivating", + null, "CULTIVATING;1", 1, 6.0)) + } + if (turboCropLvl != 5) { + cropSpecificUpgrades.add(FortuneUpgrade("§7Enchant your ${tool.displayName} §7with ${crop.getTurboCrop().replace("_", " ")} ${turboCropLvl + 1}", + null, "${crop.getTurboCrop().uppercase()};1", getNeededBooks(turboCropLvl), 5.0)) + } + recombobulateItem(tool, cropSpecificUpgrades) + when (tool.getReforgeName()) { + "blessed" -> {} + "bountiful" -> {} + else -> { + reforgeItem(tool, FarmingReforges.BLESSED, cropSpecificUpgrades) + } + } + cropSpecificUpgrades.populateAndSort(0) + } + + private fun recombobulateItem(item: ItemStack, list: MutableList) { + if (item.isRecombobulated()) return + val reforge = item.getReforgeName()?.let { FarmingReforges.valueOf(it.uppercase()) } ?: return + + FarmingFortuneDisplay.loadFortuneLineData(item, 0.0) + val increase = reforge[item.getItemRarity() + 1, FarmingFortuneDisplay.reforgeFortune] ?: return + list.add(FortuneUpgrade("§7Recombobulate your ${item.displayName}", + null, "RECOMBOBULATOR_3000", 1, increase)) + } + + private fun reforgeItem(item: ItemStack, reforge: FarmingReforg