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: Accessory MP as stack size #2243

Merged
merged 34 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
706eefb
feat: mp as stack size
minhperry Jul 20, 2024
9ba8a35
fix: fix edge cases
minhperry Jul 20, 2024
fe75cb8
refactor: rename and restructure variables
minhperry Jul 20, 2024
7f71190
refactor: spacing
minhperry Jul 20, 2024
a05c6d8
test: add regex tests
minhperry Jul 21, 2024
491fff0
refactor: move and rename class to correct place
minhperry Jul 21, 2024
c7da6c6
fix: resolving conversations pt 1
minhperry Jul 21, 2024
d53cc47
fix: resolving conversations pt final / re-add isAcc
minhperry Jul 21, 2024
e954d31
clean: cleanup spaces
minhperry Jul 21, 2024
589e7d8
fix: map -> fun
minhperry Jul 21, 2024
7c4d267
refactor: change 4 convention
minhperry Jul 21, 2024
7e44efa
feat: add edge case abicases
minhperry Jul 22, 2024
5e0f150
fix: pattern for AH
minhperry Jul 24, 2024
bf467aa
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Jul 24, 2024
3587ce9
fix: use built-in rarity detection
minhperry Jul 24, 2024
1e4b275
Merge remote-tracking branch 'origin/mp-stack-size' into mp-stack-size
minhperry Jul 24, 2024
b20f956
clean: cleanup debug code
minhperry Jul 24, 2024
e0b54fd
fix: resolving Thunder's conversations pt 1
minhperry Jul 25, 2024
5cd784a
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Jul 28, 2024
5ebab78
fixed regex test
hannibal002 Jul 28, 2024
8cb6a11
formatting
hannibal002 Jul 28, 2024
004b5d6
Merge branch 'hannibal002:beta' into mp-stack-size
minhperry Aug 14, 2024
ffee790
fix: resolving Thunder's conversations pt 2
minhperry Aug 19, 2024
e832a22
fix: resolving Hanni's conv pt 1
minhperry Aug 19, 2024
2e53def
Merge remote-tracking branch 'origin/mp-stack-size' into mp-stack-size
minhperry Aug 19, 2024
8cd35dd
refactor: regex tests
minhperry Aug 19, 2024
5e06829
fix: default to 0 contact
minhperry Aug 19, 2024
561adeb
fix: nullability 2
minhperry Aug 21, 2024
511fbe4
fix: nullability 2.5
minhperry Aug 21, 2024
3cb2167
Merge branch 'beta' into mp-stack-size
minhperry Aug 26, 2024
ce36e85
Merge branch 'hannibal002:beta' into mp-stack-size
minhperry Aug 26, 2024
7d2496a
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Sep 7, 2024
a3b9ec3
fixed regex tests not working
hannibal002 Sep 7, 2024
603583e
code cleanup
hannibal002 Sep 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public class InventoryConfig {
@Accordion
public PageScrollingConfig pageScrolling = new PageScrollingConfig();

@Expose
@ConfigOption(name = "Magical Power Display", desc = "")
@Accordion
public MagicalPowerConfig magicalPower = new MagicalPowerConfig();

@Expose
@ConfigOption(name = "Item Number", desc = "Showing the item number as a stack size for these items.")
@ConfigEditorDraggableList
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package at.hannibal2.skyhanni.config.features.inventory;

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

public class MagicalPowerConfig {
@Expose
@ConfigOption(name = "Magical Power Display", desc = "Show Magical Power as stack size inside Accessory Bag and Auction House.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;

@Expose
@ConfigOption(name = "Colored", desc = "Whether to make the numbers colored.")
@ConfigEditorBoolean
public boolean colored = false;
minhperry marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ public static class WardrobeStorage {
public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null;

@Expose
@Nullable
public Integer abiphoneContactAmount = null;

public Map<Integer, HoppityEventStats> hoppityEventStats = new HashMap<>();

public static class HoppityEventStats {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzRarity
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.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object MagicalPowerDisplay {
private val config get() = SkyHanniMod.feature.inventory.magicalPower
private var contactAmount: Int?
get() = ProfileStorageData.profileSpecific?.abiphoneContactAmount
private set(value) {
ProfileStorageData.profileSpecific?.abiphoneContactAmount = value
}

private val hegemonyArtifact = "HEGEMONY_ARTIFACT".asInternalName()
private val riftPrism = "RIFT_PRISM".asInternalName()

/**
* REGEX-TEST: Accessory Bag
* REGEX-TEST: Accessory Bag (1/75)
* REGEX-TEST: Accessory Bag (909/394294)
* REGEX-TEST: Auctions Browser
* REGEX-TEST: Auctions: "ligma"
* REGEX-TEST: Auctions: ""sugoma""
* */
private val acceptedInvPattern by RepoPattern.pattern(
minhperry marked this conversation as resolved.
Show resolved Hide resolved
"inv.acceptable",
"^(Accessory Bag(?: \\(\\d+\\/\\d+\\))?|Auctions Browser|Manage Auctions|Auctions: \".*\"?)$",
)

private val abiphoneGroup = RepoPattern.group("data.abiphone")

/**
* REGEX-TEST: Abiphone X Plus
* REGEX-TEST: Abiphone X Plus Special Edition
* REGEX-TEST: Abiphone XI Ultra Style
* REGEX-TEST: Abiphone XII Mega Color
* REGEX-TEST: Abiphone XIII Pro
* REGEX-TEST: Abiphone XIV Enormous Purple
* REGEX-TEST: Abiphone Flip
* */
private val abiphoneNamePattern by abiphoneGroup.pattern(
"name",
"Abiphone .*",
)

/**
* REGEX-TEST: Your contacts: 0/0
* REGEX-TEST: Your contacts: 1/75
* REGEX-TEST: Your contacts: 52/60
* */
private val yourContactPattern by abiphoneGroup.pattern(
"contacts",
"Your contacts: (?<contacts>\\d+)\\/\\d+",
)

@SubscribeEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
if (!isEnabled()) return
if (!acceptedInvPattern.matches(InventoryUtils.openInventoryName().removeColor())) return

val item = event.stack
val rarity = item.getAccessoryRarityOrNull() ?: return
val internalName = item.getInternalNameOrNull() ?: return

var endMP = rarity.toMP() ?: ErrorManager.skyHanniError(
"Unknown rarity '$rarity' for item '${item.displayName}§7'",
)

when (internalName) {
hegemonyArtifact -> endMP *= 2
riftPrism -> endMP = 11
else -> if (internalName.isAbicase()) endMP += (contactAmount ?: 0) / 2
}

event.stackTip = "${if (config.colored) rarity.chatColorCode else "§7"}${endMP}"
}

@SubscribeEvent
fun onInventoryOpened(event: InventoryFullyOpenedEvent) {
if (!isEnabled()) return
if (!abiphoneNamePattern.matches(event.inventoryName)) return

val theBookLore = event.inventoryItems[51]?.getLore() ?: return
for (line in theBookLore) {
yourContactPattern.matchMatcher(line.removeColor()) {
contactAmount = group("contacts").toInt()
return
}
}
}

private fun NEUInternalName.isAbicase(): Boolean = this.startsWith("ABICASE_")

private fun LorenzRarity.toMP(): Int? = when (this) {
LorenzRarity.COMMON, LorenzRarity.SPECIAL -> 3
LorenzRarity.UNCOMMON, LorenzRarity.VERY_SPECIAL -> 5
LorenzRarity.RARE -> 8
LorenzRarity.EPIC -> 12
LorenzRarity.LEGENDARY -> 16
LorenzRarity.MYTHIC -> 22
else -> null
}

private fun ItemStack.getAccessoryRarityOrNull(): LorenzRarity? {
val category = this.getItemCategoryOrNull() ?: return null
if (category != ItemCategory.ACCESSORY && category != ItemCategory.HATCESSORY) return null
return this.getItemRarityOrNull()
}

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