From 064e1f757d87b9a875dc3d26a1904213e36925ef Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 15 May 2023 15:59:19 +0200 Subject: Renamed ContestRank to ContestBracket --- .../skyhanni/features/garden/contest/ContestBracket.kt | 11 +++++++++++ .../skyhanni/features/garden/contest/ContestRank.kt | 11 ----------- .../skyhanni/features/garden/contest/FarmingContest.kt | 2 +- .../features/garden/contest/FarmingContestAPI.kt | 18 +++++++++--------- .../garden/contest/JacobContestFFNeededDisplay.kt | 14 +++++++------- .../features/garden/contest/JacobContestTimeNeeded.kt | 4 ++-- 6 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestRank.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt new file mode 100644 index 000000000..4218f0e41 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.features.garden.contest + +enum class ContestBracket(val color: String) { + GOLD("6"), + SILVER("f"), + BRONZE("c"), + ; + + val displayName = "§$color§l$name" + val pattern = "$displayName §7\\(§bTop \\d{1,2}%§7\\): §$color(?.*)".toPattern() +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestRank.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestRank.kt deleted file mode 100644 index 5bae5ef0d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestRank.kt +++ /dev/null @@ -1,11 +0,0 @@ -package at.hannibal2.skyhanni.features.garden.contest - -enum class ContestRank(val color: String) { - GOLD("6"), - SILVER("f"), - BRONZE("c"), - ; - - val displayName = "§$color§l$name" - val pattern = "$displayName §7\\(§bTop \\d{1,2}%§7\\): §$color(?.*)".toPattern() -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContest.kt index 03fb4b0a8..5bf2da85c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContest.kt @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.features.garden.contest import at.hannibal2.skyhanni.features.garden.CropType -data class FarmingContest(val time: Long, val crop: CropType, val ranks: Map) \ No newline at end of file +data class FarmingContest(val time: Long, val crop: CropType, val brackets: Map) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 3f943d037..a9f05f615 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -55,29 +55,29 @@ object FarmingContestAPI { cropPattern.matchMatcher(it) { CropType.getByName(group("crop")) } } ?: error("Crop not found in lore!") - val ranks = ContestRank.values().associateWith { rank -> + val brackets = ContestBracket.values().associateWith { bracket -> lore.firstNotNullOfOrNull { - rank.pattern.matchMatcher(it) { + bracket.pattern.matchMatcher(it) { group("amount").replace(",", "").toInt() } - } ?: error("Farming contest rank not found in lore!") + } ?: error("Farming contest bracket not found in lore!") } - return FarmingContest(time, crop, ranks) + return FarmingContest(time, crop, brackets) } fun getContestAtTime(time: Long) = contests[time] fun getContestsOfType(crop: CropType) = contests.values.filter { it.crop == crop } - fun calculateAverages(crop: CropType): Pair> { + fun calculateAverages(crop: CropType): Pair> { var amount = 0 - val map = mutableMapOf() + val map = mutableMapOf() for (contest in getContestsOfType(crop).associateWith { it.time }.sortedDesc().keys) { amount++ - for ((rank, count) in contest.ranks) { - val old = map.getOrDefault(rank, 0) - map[rank] = count + old + for ((bracket, count) in contest.brackets) { + val old = map.getOrDefault(bracket, 0) + map[bracket] = count + old } if (amount == 10) break } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt index 7e45a9fe3..cd8295ebe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt @@ -59,15 +59,15 @@ class JacobContestFFNeededDisplay { val crop = contest.crop add(listOf("§7For this ", crop.icon, "§7${crop.cropName} contest:")) - for (rank in ContestRank.values()) { - addAsSingletonList(getLine(rank, contest.ranks, crop)) + for (bracket in ContestBracket.values()) { + addAsSingletonList(getLine(bracket, contest.brackets, crop)) } addAsSingletonList("") val (size, averages) = FarmingContestAPI.calculateAverages(crop) add(listOf("§7For the last §e$size ", crop.icon, "§7${crop.cropName} contests:")) - for (rank in ContestRank.values()) { - addAsSingletonList(getLine(rank, averages, crop)) + for (bracket in ContestBracket.values()) { + addAsSingletonList(getLine(bracket, averages, crop)) } addAsSingletonList("") @@ -107,12 +107,12 @@ class JacobContestFFNeededDisplay { return ceil(ff).addSeparators() } - private fun getLine(rank: ContestRank, map: Map, crop: CropType): String { - val counter = map[rank]!! + private fun getLine(bracket: ContestBracket, map: Map, crop: CropType): String { + val counter = map[bracket]!! val blocksPerSecond = crop.getLatestBlocksPerSecond() ?: 20.0 val cropsPerSecond = counter.toDouble() / blocksPerSecond / 60 val farmingFortune = formatFarmingFortune(cropsPerSecond * 100 / 20 / crop.baseDrops) - return " ${rank.displayName}§f: §6$farmingFortune FF §7(${counter.addSeparators()} crops)" + return " ${bracket.displayName}§f: §6$farmingFortune FF §7(${counter.addSeparators()} crops)" } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt index 94498ed69..c63f01069 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt @@ -22,7 +22,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class JacobContestTimeNeeded { private val config get() = SkyHanniMod.feature.garden private var display = listOf>() - private var currentBracket = ContestRank.GOLD + private var currentBracket = ContestBracket.GOLD @SubscribeEvent(priority = EventPriority.LOW) fun onLateInventoryOpen(event: LateInventoryOpenEvent) { @@ -97,7 +97,7 @@ class JacobContestTimeNeeded { this.display = buildList { addAsSingletonList("§e§lTime Needed for ${currentBracket.displayName} §eMedal!") - addSelector("§7Bracket: ", ContestRank.values(), + addSelector("§7Bracket: ", ContestBracket.values(), getName = { type -> type.name.lowercase() }, isCurrent = { it == currentBracket }, onChange = { -- cgit