-
-
Notifications
You must be signed in to change notification settings - Fork 192
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: Fann pet leveling costs Coins/XP and XP/Bits #2604
base: beta
Are you sure you want to change the base?
Conversation
src/main/java/at/hannibal2/skyhanni/config/features/inventory/FannCostConfig.java
Outdated
Show resolved
Hide resolved
src/main/java/at/hannibal2/skyhanni/config/features/inventory/FannCostConfig.java
Outdated
Show resolved
Hide resolved
// To avoid duplicate code | ||
private fun <T> Pattern.read(lore: List<String>, func: (String) -> T): T? { | ||
for (line in lore) { | ||
val linePlain = line.removeColor() | ||
val matcher = matcher(linePlain) | ||
if (matcher.find()) { | ||
val res = matcher.group(1) | ||
return func(res) | ||
} | ||
} | ||
return null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im sure a function that does this is already in RegexUtils
src/main/java/at/hannibal2/skyhanni/features/inventory/FannCost.kt
Outdated
Show resolved
Hide resolved
src/main/java/at/hannibal2/skyhanni/features/inventory/FannCost.kt
Outdated
Show resolved
Hide resolved
src/main/java/at/hannibal2/skyhanni/features/inventory/FannCost.kt
Outdated
Show resolved
Hide resolved
for (line in this) { | ||
val linePlain = line.removeColor() | ||
val matcher = durationPattern.matcher(linePlain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use Pattern.firstMatcher(list)
src/main/java/at/hannibal2/skyhanni/features/inventory/FannCost.kt
Outdated
Show resolved
Hide resolved
private fun MutableList<String>.insertLineAfter(pattern: Pattern, content: String) { | ||
val iter = this.listIterator() | ||
while (iter.hasNext()) { | ||
val line = iter.next().removeColor() | ||
if (pattern.matcher(line).find()) { | ||
iter.add(content) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a cool function that could be used elsewhere in the mod, maybe move it to a utils class such as collection utils
private val trainingSlotInventoryPattern by patternGroup.pattern( | ||
"training", | ||
"Training Slot [1-3]", | ||
) | ||
private val anvilPattern by patternGroup.pattern( | ||
"anvil", | ||
"§aBegin Training", | ||
) | ||
private val expEarnedPattern by patternGroup.pattern( | ||
"exp.total", | ||
"""Will earn a total of (\d{1,3}(?:,\d{3})*(?:\.\d+)?|\d+\.?\d*) EXP\.?""", | ||
) | ||
private val dailyExpPattern by patternGroup.pattern( | ||
"exp.daily", | ||
"""EXP Per Day: ([\d,]+)(?: \(\+\d{1,2}(\.\d{1,2})?%\))?""", | ||
) | ||
private val durationPattern by patternGroup.pattern( | ||
"training.duration.pattern", | ||
"""Will take: (?<day>\d+)d (?<hr>\d{1,2})h (?<min>\d{1,2})m (?<sec>\d{1,2})s""", | ||
) | ||
private val coinsPattern by patternGroup.pattern( | ||
"coin", | ||
"""(\d{1,3}(?:,\d{3})*(?:\.\d+)?|\d+\.?\d*) Coins(?: \([1-5]% off\))?""", | ||
) | ||
private val bitsPattern by patternGroup.pattern( | ||
"bits", | ||
"""(\d{1,3}(?:,\d{3})*(?:\.\d+)?|\d+\.?\d*) Bits""", | ||
) | ||
private val desiredLevelPatter by patternGroup.pattern( | ||
"slot24.name.level", | ||
"Desired Level: (200|1?[0-9]?[0-9])", | ||
) | ||
private val userInputPattern by patternGroup.pattern( | ||
"slot24.name.input", | ||
"User Input", | ||
) | ||
private val trainingTypePattern by patternGroup.pattern( | ||
"training.type", | ||
"Type: (Free|Light|Moderate|Expert|Ultra|Turbo!)", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these need regex tests, they also need named pattern groups and none of them should include triple quotes
This pull request has conflicts with the base branch "beta". Please resolve those so we can test out your changes. |
What
https://discord.com/channels/997079228510117908/1192656223741427804
Images
Changelog New Features