diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt | 71 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt | 23 |
2 files changed, 72 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt new file mode 100644 index 000000000..b76861818 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt @@ -0,0 +1,71 @@ +package at.hannibal2.skyhanni.features.bingo + +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getCachedIngredients +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe + +object FirstMinionTier { + + fun firstMinionTier( + otherItems: Map<NEUInternalName, Int>, + minions: MutableMap<String, NEUInternalName>, + tierOneMinions: MutableList<NEUInternalName>, + tierOneMinionsDone: MutableList<String>, + ) { + val help = helpMap(otherItems) + val tierOneMinionsFiltered = getTierOneMinionsFiltered(tierOneMinions, tierOneMinionsDone) + addMinion(tierOneMinionsFiltered, minions, tierOneMinionsDone) + addMoreMinions(tierOneMinionsFiltered, help, minions) + } + + private fun addMoreMinions( + tierOneMinionsFiltered: List<NEUInternalName>, + help: Map<NEUInternalName, Int>, + minions: MutableMap<String, NEUInternalName> + ) { + for (minionId in tierOneMinionsFiltered) { + for (recipe in NEUItems.getRecipes(minionId)) { + if (recipe !is CraftingRecipe) continue + checkOne(recipe, help, minions, minionId) + } + } + } + + private fun checkOne( + recipe: CraftingRecipe, + help: Map<NEUInternalName, Int>, + minions: MutableMap<String, NEUInternalName>, + minionId: NEUInternalName + ) { + if (recipe.getCachedIngredients().any { help.contains(it.internalItemId.asInternalName()) }) { + val name = recipe.output.itemStack.name!!.removeColor() + val abc = name.replace(" I", " 0") + minions[abc] = minionId.replace("_1", "_0") + } + } + + private fun addMinion( + tierOneMinionsFiltered: List<NEUInternalName>, + minions: MutableMap<String, NEUInternalName>, + tierOneMinionsDone: MutableList<String> + ) { + for (minionId in tierOneMinionsFiltered) { + val prefix = minionId.asString().dropLast(1) + if (minions.any { it.value.startsWith(prefix) }) { + tierOneMinionsDone.add(minionId.toString()) + } + } + } + + private fun getTierOneMinionsFiltered( + tierOneMinions: MutableList<NEUInternalName>, + tierOneMinionsDone: MutableList<String> + ) = tierOneMinions.filter { it.asString() !in tierOneMinionsDone } + + private fun helpMap(otherItems: Map<NEUInternalName, Int>) = + otherItems.filter { !it.key.startsWith("WOOD_") } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index 671b42848..227c4fd58 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -117,7 +117,7 @@ class MinionCraftHelper { } } - firstMinionTier(otherItems, minions) + FirstMinionTier.firstMinionTier(otherItems, minions, tierOneMinions, tierOneMinionsDone) return Pair(minions, otherItems) } @@ -170,27 +170,6 @@ class MinionCraftHelper { } } - private fun firstMinionTier(otherItems: Map<NEUInternalName, Int>, minions: MutableMap<String, NEUInternalName>) { - val help = otherItems.filter { !it.key.startsWith("WOOD_") } - val tierOneMinionsFiltered = tierOneMinions.filter { it.asString() !in tierOneMinionsDone } - for (minionId in tierOneMinionsFiltered) { - val prefix = minionId.asString().dropLast(1) - if (minions.any { it.value.startsWith(prefix) }) { - tierOneMinionsDone.add(minionId.toString()) - } - } - for (minionId in tierOneMinionsFiltered) { - for (recipe in NEUItems.getRecipes(minionId)) { - if (recipe !is CraftingRecipe) continue - if (recipe.getCachedIngredients().any { help.contains(it.internalItemId.asInternalName()) }) { - val name = recipe.output.itemStack.name!!.removeColor() - val abc = name.replace(" I", " 0") - minions[abc] = minionId.replace("_1", "_0") - } - } - } - } - private fun addMinion( name: String, minionTier: Int, |