Skip to content
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: All-Time Hoppity Stats #3242

Open
wants to merge 54 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
df8315e
Done
DavidArthurCole Dec 22, 2024
32e09db
Revert "Done"
DavidArthurCole Dec 22, 2024
652b65a
Done, again
DavidArthurCole Dec 22, 2024
715f587
Deal with migrations, todos
DavidArthurCole Dec 23, 2024
f3f1599
Fix
DavidArthurCole Jan 1, 2025
3a3ae28
Done
DavidArthurCole Jan 2, 2025
01042ca
Fix
DavidArthurCole Jan 2, 2025
a3181fc
Fix
DavidArthurCole Jan 2, 2025
6cc8060
Fix formatting
DavidArthurCole Jan 2, 2025
cfa0929
Merge
DavidArthurCole Jan 2, 2025
47ba1c1
Cleanup
DavidArthurCole Jan 2, 2025
8cdfa25
Future proofing
DavidArthurCole Jan 2, 2025
0eb6691
Formatting
DavidArthurCole Jan 2, 2025
ed03023
Fix config
DavidArthurCole Jan 2, 2025
7bcc8a7
Fix index
DavidArthurCole Jan 2, 2025
43379e2
Merge
DavidArthurCole Jan 4, 2025
2a0b9f0
Merge remote-tracking branch 'upstream/beta' into HoppityUnDupCounter
DavidArthurCole Jan 6, 2025
cffdc7e
Fix overdisplay
DavidArthurCole Jan 6, 2025
eeaa2a0
add helper methods for enum maps and some cleanup in storage
ItsEmpa Jan 10, 2025
2184823
oops
ItsEmpa Jan 10, 2025
5c68258
remove static durations
ItsEmpa Jan 11, 2025
8e3ea50
suppress detekt
ItsEmpa Jan 11, 2025
191667e
Merge branch 'refs/heads/beta' into fork/ItsEmpa/backend/enum-map-helper
CalMWolfs Jan 12, 2025
7819943
regression
CalMWolfs Jan 12, 2025
0bafc99
Merge branch 'beta' into HoppityUnDupCounter
DavidArthurCole Jan 14, 2025
9e08eed
Merge branch 'beta' into backend/enum-map-helper
CalMWolfs Jan 16, 2025
a531157
Merge branch 'beta' into backend/enum-map-helper
CalMWolfs Jan 16, 2025
a9c5aea
Merge branch 'beta' into HoppityUnDupCounter
CalMWolfs Jan 16, 2025
19a97ed
Done
DavidArthurCole Jan 17, 2025
ba7ffc0
Update
DavidArthurCole Jan 17, 2025
5714d12
More improvements
DavidArthurCole Jan 17, 2025
86ebb6a
Updates
DavidArthurCole Jan 17, 2025
32a6c7c
Merge branch 'HoppityUnDupCounter' into HoppityAllTimeStats
DavidArthurCole Jan 17, 2025
3951b3b
Merge
DavidArthurCole Jan 17, 2025
ffcffef
Merge cleanup
DavidArthurCole Jan 17, 2025
4a10305
Done
DavidArthurCole Jan 18, 2025
4b1435b
Fix
DavidArthurCole Jan 18, 2025
14b1583
Merge
DavidArthurCole Jan 20, 2025
f54e96d
Merge
DavidArthurCole Jan 20, 2025
a5747d3
Fixes
DavidArthurCole Jan 20, 2025
86e9502
Merge
DavidArthurCole Jan 20, 2025
753c863
Cleanup
DavidArthurCole Jan 20, 2025
8627b9e
Fixes
DavidArthurCole Jan 22, 2025
3e5d675
Detekt
DavidArthurCole Jan 22, 2025
b7a0f6e
Fix
DavidArthurCole Jan 23, 2025
029cb75
Fuck
DavidArthurCole Jan 23, 2025
6b7de4b
Merge
DavidArthurCole Jan 23, 2025
77ee29a
Merge branch 'beta' into HoppityAllTimeStats
DavidArthurCole Jan 24, 2025
80682c0
Merge branch 'refs/heads/beta' into fork/DavidArthurCole/HoppityAllTi…
CalMWolfs Jan 24, 2025
1c2ee82
Merge branch 'beta' into HoppityAllTimeStats
DavidArthurCole Jan 24, 2025
b7d1e33
Merge
DavidArthurCole Jan 24, 2025
e87140a
Merge branch 'beta' into HoppityAllTimeStats
DavidArthurCole Jan 24, 2025
347e9d3
Merge
DavidArthurCole Jan 25, 2025
343ccb3
Merge
DavidArthurCole Jan 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.github.notenoughupdates.moulconfig.annotations.Accordion;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;
Expand Down Expand Up @@ -65,9 +64,9 @@ public enum HoppityStat {
SIDE_DISH_EGGS("§7You found §b4 §6§lSide Dish Eggs §r§7in the §6Chocolate Factory§7."),
MILESTONE_RABBITS("§7You claimed §b2 §6§lMilestone Rabbits§7."),
EMPTY_1(""),
NEW_RABBITS("§7Unique Rabbits: §b7\n §f1 §7- §a1 §7- §91 §7- §51 §7- §61 §7- §d1 §7- §b1"),
NEW_RABBITS("§7Unique Rabbits: §f7\n §f1 §7- §a1 §7- §91 §7- §51 §7- §61 §7- §d1 §7- §b1"),
EMPTY_2(""),
DUPLICATE_RABBITS("§7Duplicate Rabbits: §c10\n §f4 §7- §a3 §7- §92 §7- §51 §7- §60 §7- §d0 §7- §b0\n §6+250,000,000 Chocolate"),
DUPLICATE_RABBITS("§7Duplicate Rabbits: §f10\n §f4 §7- §a3 §7- §92 §7- §51 §7- §60 §7- §d0 §7- §b0\n §6+250,000,000 Chocolate"),
EMPTY_3(""),
STRAY_RABBITS("§7Stray Rabbits: §f20\n §f10 §7- §a6 §7- §93 §7- §51 §7- §60 §7- §d0 §7- §b0\n §6+8,000,000 Chocolate\n §4* §c§oRequires Stray Tracker being enabled to work§4§o."),
EMPTY_4(""),
Expand All @@ -87,4 +86,13 @@ public String toString() {
return display;
}
}

@Expose
@ConfigOption(
name = "Show Count Diff",
desc = "Store and display the count of Uniques/Duplicates next to their respective rabbit count.\n" +
".e.g. §7Unique Rabbits: §f5 §7(270 -> 275)"
)
@ConfigEditorBoolean
public boolean showCountDiff = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public String toString() {
@ConfigEditorDropdown
public HoppityDateTimeFormat dateTimeFormat = HoppityDateTimeFormat.RELATIVE;

@Expose
@ConfigOption(
name = "Show All-Time",
desc = "Add a dummy \"All-Time\" entry after the last set of stats, showing the total stats for all recorded events."
)
@ConfigEditorBoolean
public boolean showAllTime = true;

@Expose
@ConfigOption(name = "Card Toggle Keybind", desc = "Toggle the GUI element with this keybind.")
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ class ProfileSpecificStorage {
@Expose
var mealLastFound: MutableMap<HoppityEggType, SimpleTimeMark> = enumMapOf()

@Expose
var mealNextSpawn: MutableMap<HoppityEggType, SimpleTimeMark> = enumMapOf()

class HitmanStatsStorage {
@Expose
var availableHitmanEggs: Int = 0
Expand Down Expand Up @@ -719,44 +722,57 @@ class ProfileSpecificStorage {
var hoppityStatLiveDisplayToggledOff: Boolean = false

data class HoppityEventStats(
@Expose
var mealsFound: MutableMap<HoppityEggType, Int> = enumMapOf(),

@Expose
var rabbitsFound: MutableMap<LorenzRarity, RabbitData> = enumMapOf(),

@Expose
var dupeChocolateGained: Long = 0,

@Expose
var strayChocolateGained: Long = 0,

@Expose
var millisInCf: Duration = Duration.ZERO,

@Expose
var rabbitTheFishFinds: Int = 0,

@Expose
var initialLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(-1, -1.0),

@Expose
var finalLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(-1, -1.0),

@Expose
var lastLbUpdate: SimpleTimeMark = farPast(),

@Expose
var summarized: Boolean = false,
@Expose var mealsFound: MutableMap<HoppityEggType, Int> = enumMapOf(),
@Expose var rabbitsFound: MutableMap<LorenzRarity, RabbitData> = enumMapOf(),
@Expose var dupeChocolateGained: Long = 0,
@Expose var strayChocolateGained: Long = 0,
@Expose var rabbitTheFishFinds: Int = 0,

@Expose var millisInCf: Duration = Duration.ZERO,
@Expose var initialLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(),
@Expose var finalLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(),
@Expose var lastLbUpdate: SimpleTimeMark = farPast(),
@Expose var summarized: Boolean = false,

@Expose var typeCountSnapshot: RabbitData = RabbitData(),
@Expose var typeCountsSince: RabbitData = RabbitData(),
) {
operator fun plusAssign(it: HoppityEventStats) {
it.mealsFound.forEach { (key, value) ->
mealsFound.merge(key, value, Int::plus)
}
it.rabbitsFound.forEach { (key, rabbitData) ->
rabbitsFound.merge(key, rabbitData) { existing, new ->
RabbitData(
uniques = existing.uniques + new.uniques,
dupes = existing.dupes + new.dupes,
strays = existing.strays + new.strays
)
}
}
dupeChocolateGained += it.dupeChocolateGained
strayChocolateGained += it.strayChocolateGained
rabbitTheFishFinds += it.rabbitTheFishFinds
millisInCf += it.millisInCf
}

companion object {
data class RabbitData(
@Expose var uniques: Int = 0,
@Expose var dupes: Int = 0,
@Expose var strays: Int = 0,
) {
fun getByIndex(index: Int): Int = when (index) {
0 -> uniques
1 -> dupes
2 -> strays
else -> throw IllegalArgumentException("Invalid index: $index")
}
}
data class LeaderboardPosition(
@Expose var position: Int = -1,
@Expose var percentile: Double = -1.0,
)

data class LeaderboardPosition(@Expose var position: Int, @Expose var percentile: Double)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage.ChocolateFactoryStorage.HotspotRabbitStorage
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ProfileStorageData
Expand All @@ -23,6 +24,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.addString
import at.hannibal2.skyhanni.utils.CollectionUtils.collectWhile
import at.hannibal2.skyhanni.utils.CollectionUtils.consumeWhile
import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues
import at.hannibal2.skyhanni.utils.CollectionUtils.sumOfPair
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.DisplayTableEntry
import at.hannibal2.skyhanni.utils.InventoryUtils
Expand Down Expand Up @@ -54,6 +57,8 @@ import net.minecraft.item.ItemStack
import java.util.regex.Pattern
import kotlin.time.Duration.Companion.seconds

private typealias RabbitData = ProfileSpecificStorage.HoppityEventStats.Companion.RabbitData

@SkyHanniModule
object HoppityCollectionStats {
private val collectionConfig get() = ChocolateFactoryApi.config.hoppityCollectionStats
Expand Down Expand Up @@ -184,12 +189,13 @@ object HoppityCollectionStats {
)
// </editor-fold>

private val profileStorage get() = ProfileStorageData.profileSpecific?.chocolateFactory
private var shCountData: HoppityEggLocationsJson? = null
private var neuCountData: HoppityInfo? = null
private var hotspotRabbitCount = 0
private var display = emptyList<Renderable>()
private val loggedRabbits
get() = ProfileStorageData.profileSpecific?.chocolateFactory?.rabbitCounts ?: mutableMapOf()
get() = profileStorage?.rabbitCounts ?: mutableMapOf()

enum class HighlightRabbitTypes(
private val displayName: String,
Expand Down Expand Up @@ -228,17 +234,17 @@ object HoppityCollectionStats {
}

private val locationRabbitRequirements: MutableMap<String, LocationRabbit>
get() = ProfileStorageData.profileSpecific?.chocolateFactory?.locationRabbitRequirements ?: mutableMapOf()
get() = profileStorage?.locationRabbitRequirements ?: mutableMapOf()

private val residentRabbitData: MutableMap<IslandType, MutableMap<String, Boolean?>>
get() = ProfileStorageData.profileSpecific?.chocolateFactory?.residentRabbits ?: mutableMapOf()
get() = profileStorage?.residentRabbits ?: mutableMapOf()

private val hotspotRabbitData: HotspotRabbitStorage?
get() = ProfileStorageData.profileSpecific?.chocolateFactory?.hotspotRabbitStorage?.let { storage ->
get() = profileStorage?.hotspotRabbitStorage?.let { storage ->
val yearNow = SkyBlockTime.now().year
if (storage.skyblockYear != yearNow) {
HotspotRabbitStorage(yearNow).also {
ProfileStorageData.profileSpecific?.chocolateFactory?.hotspotRabbitStorage = it
profileStorage?.hotspotRabbitStorage = it
}
} else storage
}
Expand Down Expand Up @@ -601,7 +607,7 @@ object HoppityCollectionStats {

val newList = mutableListOf<Renderable>()
newList.add(Renderable.string("§eHoppity Rabbit Collection§f:"))
newList.add(LorenzUtils.fillTable(getRabbitStats(), padding = 5))
newList.add(LorenzUtils.fillTable(getRabbitStatsFormat(), padding = 5))

addLocationRequirementRabbitsToHud(newList)
addResidentRabbitsInformationToHud(newList)
Expand All @@ -622,7 +628,27 @@ object HoppityCollectionStats {
return newList
}

private fun getRabbitStats(): MutableList<DisplayTableEntry> {
fun getTypeCountSnapshot(): RabbitData {
val (uniqueCount, duplicateCount) = RabbitCollectionRarity.entries.sumOfPair(
selector = { rarity ->
val foundOfRarity = loggedRabbits.filterKeys {
HoppityCollectionData.getRarity(it) == rarity
}
val uniquesFound = foundOfRarity.size
val duplicates = foundOfRarity.values.sum() - uniquesFound
uniquesFound to duplicates
},
resultConverter = Double::toInt
)

return RabbitData(
uniques = uniqueCount,
dupes = duplicateCount,
strays = profileStorage?.strayTracker?.straysCaught?.sumAllValues()?.toInt() ?: 0,
)
}

private fun getRabbitStatsFormat(): MutableList<DisplayTableEntry> {
var totalUniquesFound = 0
var totalDuplicates = 0
var totalChocolatePerSecond = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ object HoppityEggDisplayManager {
HoppityEggType.resettingEntries.filter {
it.hasRemainingSpawns() // Only show eggs that have future spawns
}.let { entries ->
if (config.unclaimedEggsOrder == SOONEST_FIRST) entries.sortedBy { it.timeUntil() }
if (config.unclaimedEggsOrder == SOONEST_FIRST) entries.sortedBy { it.timeUntil }
else entries
}.forEach { add("§7 - ${it.formattedName} ${it.timeUntil().format()}") }
}.forEach { add("§7 - ${it.formattedName} ${it.timeUntil.format()}") }

if (!config.showCollectedLocationCount || !LorenzUtils.inSkyBlock) return@buildList

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ object HoppityEggLocator {
lastParticlePosition = null
}

fun mealSpawned(meal: HoppityEggType) {
if (currentEggType == meal) resetData()
}

@HandleEvent
fun onRenderWorld(event: SkyHanniRenderWorldEvent) {
if (!isEnabled()) return
Expand Down Expand Up @@ -170,7 +174,7 @@ object HoppityEggLocator {
drawDynamicText(location.up(), possibleDuplicateLabel, 1.5)
}

private fun shouldShowAllEggs() = config.showAllWaypoints && !locatorInHotbar && HoppityEggType.eggsRemaining()
private fun shouldShowAllEggs() = config.showAllWaypoints && !locatorInHotbar && HoppityEggType.anyEggsUnclaimed()

@HandleEvent(onlyOnSkyblock = true)
fun onReceiveParticle(event: ReceiveParticleEvent) {
Expand Down
Loading
Loading