Skip to content

Commit

Permalink
Fix: Hoppity > max (#2688)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Oct 7, 2024
1 parent 129bc89 commit 1de910a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public static class ChocolateFactoryStorage {
@Expose
public long currentChocolate = 0;

@Expose
public long maxChocolate = 0;

@Expose
public long chocolateThisPrestige = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class ChocolateAmount(val chocolate: () -> Long) {

companion object {
fun chocolateSinceUpdate(): Long {
if (ChocolateFactoryAPI.isMax()) return 0L
val lastUpdate = profileStorage?.lastDataSave ?: return 0
val currentTime = SimpleTimeMark.now()
val secondsSinceUpdate = (currentTime - lastUpdate).inWholeSeconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@ object ChocolateFactoryAPI {
it.rabbit.removeColor() == rabbitName.removeColor()
}
}

fun isMax(): Boolean = profileStorage?.let {
it.maxChocolate == it.currentChocolate
} ?: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ object ChocolateFactoryDataLoader {
"chocolate.thisprestige",
"§7Chocolate this Prestige: §6(?<amount>[\\d,]+)",
)

/**
* REGEX-TEST: §7Max Chocolate: §660B
*/
private val maxChocolatePattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.max",
"§7Max Chocolate: §6(?<max>.*)",
)
private val chocolateForPrestigePattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.forprestige",
"§7§cRequires (?<amount>\\w+) Chocolate this.*",
Expand Down Expand Up @@ -230,6 +238,9 @@ object ChocolateFactoryDataLoader {
chocolateThisPrestigePattern.matchMatcher(line) {
profileStorage.chocolateThisPrestige = group("amount").formatLong()
}
maxChocolatePattern.matchMatcher(line) {
profileStorage.maxChocolate = group("max").formatLong()
}
chocolateForPrestigePattern.matchMatcher(line) {
ChocolateFactoryAPI.chocolateForPrestige = group("amount").formatLong()
prestigeCost = ChocolateFactoryAPI.chocolateForPrestige
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ object ChocolateFactoryStats {
val map = buildMap<ChocolateFactoryStat, String> {
put(ChocolateFactoryStat.HEADER, "§6§lChocolate Factory ${ChocolateFactoryAPI.currentPrestige.toRoman()}")

put(ChocolateFactoryStat.CURRENT, "§eCurrent Chocolate: §6${ChocolateAmount.CURRENT.formatted}")
val maxSuffix = if (ChocolateFactoryAPI.isMax()) {
" §cMax!"
} else ""
put(ChocolateFactoryStat.CURRENT, "§eCurrent Chocolate: §6${ChocolateAmount.CURRENT.formatted}$maxSuffix")
put(ChocolateFactoryStat.THIS_PRESTIGE, "§eThis Prestige: §6${ChocolateAmount.PRESTIGE.formatted}")
put(ChocolateFactoryStat.ALL_TIME, "§eAll-time: §6${ChocolateAmount.ALL_TIME.formatted}")

Expand Down

0 comments on commit 1de910a

Please sign in to comment.