SkyHanni
SkyHanni copied to clipboard
Wrong/broken Changelog: ItemSocket
Note
Feedback on the proposed idea is appreciated. I'll be waiting for feedback before proceeding with full implementation.
What
This pull request introduces an abstraction for retrieving a specific item from the user. The concept revolves around defining the desired item and obtaining the closest matching item from the user's inventory. Is intended to replace most of the captureFarmingGear logic.
It has 3 layers to determining the item:
- ItemCategory - default any
- InternalName - as Pattern to match one or multiple items - default any
- evalaution - a comparison function that determines whether the newly captured item should replace the old one - default true
Pros
- Easy of use
- Improved readability
- Independent from any feature
- Generalized for any item
- Simplifies /ff and allows for similar features
Examples
private val farmingSets = arrayListOf(
"FERMENTO", "SQUASH", "CROPIE", "MELON", "FARM",
"RANCHERS", "FARMER", "RABBIT"
)
private val patternGearGroup = patternGroup.group("gear")
private val socketKeyPrefix = "guide.farming."
private val farmingSetsPattern by patternGearGroup.pattern("sets", "(?:${farmingSets.joinToString { "|" }}).*")
val helmet = ItemSocket("${socketKeyPrefix}helmet", ItemCategory.HELMET, farmingSetsPattern)
val chestPlate = ItemSocket("${socketKeyPrefix}chestPlate", ItemCategory.CHESTPLATE, farmingSetsPattern)
val leggings = ItemSocket("${socketKeyPrefix}leggings", ItemCategory.LEGGINGS, farmingSetsPattern)
val boots = ItemSocket("${socketKeyPrefix}boots", ItemCategory.BOOTS, farmingSetsPattern)
val necklace = ItemSocket("${socketKeyPrefix}necklace", ItemCategory.NECKLACE, equipmentPattern)
val cloak = ItemSocket("${socketKeyPrefix}cloak", ItemCategory.CLOAK, equipmentPattern)
val belt = ItemSocket("${socketKeyPrefix}belt", ItemCategory.BELT, equipmentPattern)
val bracelet = ItemSocket("${socketKeyPrefix}bracelet", ItemCategory.BRACELET, equipmentPattern)
private val petCompare: (ItemStack, ItemStack) -> Boolean = { old, new ->
val oldRarityId = old.getItemRarityOrNull()?.id ?: 0
val newRarityId = new.getItemRarityOrNull()?.id ?: 0
(oldRarityId < newRarityId) || (oldRarityId == newRarityId && old.getPetLevel() < new.getPetLevel())
}
val elphant = ItemSocket("${socketKeyPrefix}elephant", ItemCategory.PET, "ELEPHANT.*".toPattern(), petCompare)
val mooshroomCow = ItemSocket("${socketKeyPrefix}mooshroomCow", ItemCategory.PET, "MOOSHROOM_COW.*".toPattern(), petCompare)
val rabbit = ItemSocket("${socketKeyPrefix}rabbit", ItemCategory.PET, "RABBIT.*".toPattern(), petCompare)
val bee = ItemSocket("${socketKeyPrefix}bee", ItemCategory.PET, "BEE.*".toPattern(), petCompare)
This pull request has conflicts with the base branch "beta". Please resolve those so we can test out your changes.
old