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: Hitman Statistics #2991

Merged
merged 41 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
29ab635
Done
DavidArthurCole Nov 26, 2024
89bf974
Detekt
DavidArthurCole Nov 26, 2024
205d602
Fix infinite loop
DavidArthurCole Nov 26, 2024
aa7c365
Impr
DavidArthurCole Nov 26, 2024
aaadd83
Detekt
DavidArthurCole Nov 26, 2024
e98bddd
Runaway prot
DavidArthurCole Nov 26, 2024
b3c11ec
....
DavidArthurCole Nov 26, 2024
16160ef
Add open slots as option
DavidArthurCole Nov 26, 2024
132f657
Possible logic fix
DavidArthurCole Nov 26, 2024
ab3fec7
Nerf full slots, stat calc is bugged
DavidArthurCole Nov 26, 2024
2c76682
Detekt
DavidArthurCole Nov 27, 2024
07d3b71
Fix bugged calcs
DavidArthurCole Nov 27, 2024
a86725d
Cap at event end
DavidArthurCole Nov 27, 2024
d96f5bc
Color when cutoff by event end
DavidArthurCole Nov 27, 2024
f760d36
Up
DavidArthurCole Nov 27, 2024
9d52095
Merge branch 'hannibal002:beta' into HoppityHitman
DavidArthurCole Nov 29, 2024
471970b
Fixes
DavidArthurCole Dec 1, 2024
d35cf2f
Revert, potential fix?
DavidArthurCole Dec 1, 2024
45e8e2b
Detekt
DavidArthurCole Dec 1, 2024
7749e87
More attempts at fixes
DavidArthurCole Dec 1, 2024
dfbf8ac
Another attempt
DavidArthurCole Dec 1, 2024
53ef120
Detekt
DavidArthurCole Dec 1, 2024
0231d09
Offset
DavidArthurCole Dec 1, 2024
c8043f5
Still broken
DavidArthurCole Dec 1, 2024
2920e85
Functional, finally
DavidArthurCole Dec 2, 2024
c83a839
Merge branch 'hannibal002:beta' into HoppityHitman
DavidArthurCole Dec 2, 2024
06f0a80
Bump
DavidArthurCole Dec 2, 2024
8377514
Bump again
DavidArthurCole Dec 2, 2024
ea8c988
Merge branch 'hannibal002:beta' into HoppityHitman
DavidArthurCole Dec 4, 2024
1c6242d
Merge branch 'beta' into HoppityHitman
DavidArthurCole Dec 5, 2024
1e9ab17
Detekt
DavidArthurCole Dec 5, 2024
e552b10
Merge branch 'refs/heads/beta' into fork/DavidArthurCole/HoppityHitman
CalMWolfs Dec 6, 2024
cfddb93
Fix logic for unclaimed eggs
DavidArthurCole Dec 6, 2024
e5c061f
Changes (gramatic and syntactic, no functionality changed)
DavidArthurCole Dec 6, 2024
0f5dc94
Merge branch 'hannibal002:beta' into HoppityHitman
DavidArthurCole Dec 9, 2024
d629d92
Merge branch 'hannibal002:beta' into HoppityHitman
DavidArthurCole Dec 10, 2024
e32999b
Requested changes
DavidArthurCole Dec 10, 2024
257174a
Fixes
DavidArthurCole Dec 11, 2024
c351912
Fix logical error
DavidArthurCole Dec 12, 2024
85e3559
Merge remote-tracking branch 'upstream/beta' into HoppityHitman
DavidArthurCole Dec 12, 2024
e6b8049
Account for available in open slots
DavidArthurCole Dec 12, 2024
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 @@ -222,7 +222,7 @@ public HotspotRabbitStorage(@Nullable Integer year) {
public static class HitmanStatsStorage {
@Expose
@Nullable
public Integer availableEggs;
public Integer availableEggs = null;

@Expose
@Nullable
Expand All @@ -231,6 +231,10 @@ public static class HitmanStatsStorage {
@Expose
@Nullable
public SimpleTimeMark allSlotsCooldown = null;

@Expose
@Nullable
public Integer purchasedSlots = null;
}

@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ object HoppityAPI {
// If there is a time since lastHoppityCallAccept, we can assume this is an abiphone call
private fun getBoughtType(): HoppityEggType = if (lastHoppityCallAccept != null) BOUGHT_ABIPHONE else BOUGHT

fun isHoppityEvent() = (SkyblockSeason.currentSeason == SkyblockSeason.SPRING || SkyHanniMod.feature.dev.debug.alwaysHoppitys)
fun getEventEndMark(): SimpleTimeMark? = if (isHoppityEvent()) {
SkyBlockTime.fromSbYearAndMonth(SkyBlockTime.now().year, 3).asTimeMark()
} else null
fun isHoppityEvent() = (SkyblockSeason.SPRING.isSeason() || SkyHanniMod.feature.dev.debug.alwaysHoppitys)
fun getEventEndMark(): SimpleTimeMark? = if (isHoppityEvent()) SkyBlockTime.now().year.getEventEndMark() else null
fun Int.getEventEndMark(): SimpleTimeMark =
SkyBlockTime.fromSeason(this, SkyblockSeason.SUMMER, SkyblockSeason.SkyblockSeasonModifier.EARLY).asTimeMark()
fun Int.getEventStartMark(): SimpleTimeMark =
SkyBlockTime.fromSeason(this, SkyblockSeason.SPRING, SkyblockSeason.SkyblockSeasonModifier.EARLY).asTimeMark()
DavidArthurCole marked this conversation as resolved.
Show resolved Hide resolved

fun rarityByRabbit(rabbit: String): LorenzRarity? = hoppityRarities.firstOrNull {
it.chatColorCode == rabbit.substring(0, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum class HoppityEggType(
val resetsAt: Int,
var lastResetDay: Int = -1,
private var claimed: Boolean = false,
private val altDay: Boolean = false
val altDay: Boolean = false
) {
BREAKFAST("Breakfast", "§6", 7),
LUNCH("Lunch", "§9", 14),
Expand Down Expand Up @@ -51,6 +51,10 @@ enum class HoppityEggType(
return now.copy(day = now.day + daysToAdd, hour = resetsAt, minute = 0, second = 0).asTimeMark().timeUntil()
}

fun nextTime(): SimpleTimeMark {
return SimpleTimeMark.now() + timeUntil()
}

fun markClaimed(mark: SimpleTimeMark? = null) {
mealLastFound[this] = mark ?: SimpleTimeMark.now()
claimed = true
Expand Down Expand Up @@ -93,6 +97,7 @@ enum class HoppityEggType(
}

val resettingEntries = entries.filter { it.resetsAt != -1 }
val sortedResettingEntries = resettingEntries.sortedBy { it.resetsAt }

fun allFound() = resettingEntries.forEach { it.markClaimed() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ object ChocolateFactoryDataLoader {
"§7Available eggs: §a(?<amount>\\d+)",
)

/**
* REGEX-TEST: §7Purchased slots: §a28§7/§a28
* REGEX-TEST: §7Purchased slots: §e0§7/§a22
*/
private val hitmanPurchasedSlotsPattern by ChocolateFactoryAPI.patternGroup.pattern(
"hitman.purchasedslots",
"§7Purchased slots: §.(?<amount>\\d+)§7\\/§a\\d+",
)

/**
* REGEX-TEST: §7Slot cooldown: §a8m 6s
*/
Expand Down Expand Up @@ -451,6 +460,9 @@ object ChocolateFactoryDataLoader {
val nextAllSlots = (SimpleTimeMark.now() + timeUntilAllSlots)
profileStorage.hitmanStats.allSlotsCooldown = nextAllSlots
}
hitmanPurchasedSlotsPattern.matchMatcher(line) {
profileStorage.hitmanStats.purchasedSlots = group("amount").formatInt()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEventSummary
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getHitmanTimeToAll
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getHitmanTimeToFull
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getOpenSlots
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ClipboardUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
Expand All @@ -16,6 +20,7 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable
import com.google.gson.JsonElement
import com.google.gson.JsonPrimitive
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration

@SkyHanniModule
object ChocolateFactoryStats {
Expand All @@ -40,6 +45,7 @@ object ChocolateFactoryStats {
config.position.renderRenderables(display, posLabel = "Chocolate Factory Stats")
}

@Suppress("LongMethod", "CyclomaticComplexMethod")
fun updateDisplay() {
val profileStorage = profileStorage ?: return

Expand Down Expand Up @@ -76,7 +82,23 @@ object ChocolateFactoryStats {

val upgradeAvailableAt = ChocolateAmount.CURRENT.formattedTimeUntilGoal(profileStorage.bestUpgradeCost)

val map = buildMap<ChocolateFactoryStat, String> {
val hitmanStats = profileStorage.hitmanStats
val availableHitmanEggs = hitmanStats.availableEggs?.takeIf { it > 0 }?.toString() ?: "§7None"
val hitmanSingleSlotCd = hitmanStats.slotCooldown?.takeIf { it.isInFuture() }?.timeUntil()?.format() ?: "§aAll Ready"
val hitmanAllSlotsCd = hitmanStats.allSlotsCooldown?.takeIf { it.isInFuture() }?.timeUntil()?.format() ?: "§aAll Ready"
val openSlotsNow = hitmanStats.getOpenSlots()
val purchasedSlots = hitmanStats.purchasedSlots ?: 0

val (hitmanAllSlotsTime, allSlotsEventInhibited) = hitmanStats.getHitmanTimeToAll()
val hitmanAllClaimString = hitmanAllSlotsTime.takeIf { it > Duration.ZERO }?.format() ?: "§aAll Ready"
val hitmanAllClaimReady = "${if (allSlotsEventInhibited) "§c" else "§b"}$hitmanAllClaimString"

val (hitmanFullTime, hitmanFullEventInhibited) = hitmanStats.getHitmanTimeToFull()
val hitmanFullString = if (openSlotsNow == 0) "§7Cooldown..."
else hitmanFullTime.takeIf { it > Duration.ZERO }?.format() ?: "§cFull Now"
val hitmanSlotsFull = "${if (hitmanFullEventInhibited) "§c" else "§b"}$hitmanFullString"

val map = buildMap {
put(ChocolateFactoryStat.HEADER, "§6§lChocolate Factory ${ChocolateFactoryAPI.currentPrestige.toRoman()}")

val maxSuffix = if (ChocolateFactoryAPI.isMax()) {
Expand Down Expand Up @@ -118,25 +140,36 @@ object ChocolateFactoryStats {
"§eRaw Per Second: §6${profileStorage.rawChocPerSecond.addSeparators()}",
)

if (ChocolateFactoryAPI.isMaxPrestige()) {
val allTime = ChocolateAmount.ALL_TIME.chocolate()
val nextChocolateMilestone = ChocolateFactoryAPI.getNextMilestoneChocolate(allTime)
val amountUntilNextMilestone = nextChocolateMilestone - allTime
val maxMilestoneEstimate = ChocolateAmount.ALL_TIME.formattedTimeUntilGoal(nextChocolateMilestone)

if (amountUntilNextMilestone >= 0) {
put(ChocolateFactoryStat.TIME_TO_PRESTIGE, "§eTime To Next Milestone: $maxMilestoneEstimate")
put(
ChocolateFactoryStat.CHOCOLATE_UNTIL_PRESTIGE,
"§eChocolate To Next Milestone: §6${amountUntilNextMilestone.addSeparators()}",
)
}
} else {
put(ChocolateFactoryStat.TIME_TO_PRESTIGE, "§eTime To Prestige: $prestigeEstimate")
put(ChocolateFactoryStat.CHOCOLATE_UNTIL_PRESTIGE, "§eChocolate To Prestige: §6$chocolateUntilPrestige")
val allTime = ChocolateAmount.ALL_TIME.chocolate()
val nextChocolateMilestone = ChocolateFactoryAPI.getNextMilestoneChocolate(allTime)
val amountUntilNextMilestone = nextChocolateMilestone - allTime
val amountFormat = amountUntilNextMilestone.addSeparators()
val maxMilestoneEstimate = ChocolateAmount.ALL_TIME.formattedTimeUntilGoal(nextChocolateMilestone)
val prestigeData = when {
!ChocolateFactoryAPI.isMaxPrestige() -> mapOf(
ChocolateFactoryStat.TIME_TO_PRESTIGE to "§eTime To Prestige: $prestigeEstimate",
ChocolateFactoryStat.CHOCOLATE_UNTIL_PRESTIGE to "§eChocolate To Prestige: §6$chocolateUntilPrestige"
)
amountUntilNextMilestone >= 0 -> mapOf(
ChocolateFactoryStat.TIME_TO_PRESTIGE to "§eTime To Next Milestone: $maxMilestoneEstimate",
ChocolateFactoryStat.CHOCOLATE_UNTIL_PRESTIGE to "§eChocolate To Next Milestone: §6$amountFormat"
)
else -> emptyMap()
}
putAll(prestigeData)

put(ChocolateFactoryStat.TIME_TO_BEST_UPGRADE, "§eBest Upgrade: $upgradeAvailableAt")

put(ChocolateFactoryStat.HITMAN_HEADER, "§c§lRabbit Hitman")
put(ChocolateFactoryStat.AVAILABLE_HITMAN_EGGS, "§eAvailable Hitman Eggs: §6$availableHitmanEggs")
put(ChocolateFactoryStat.OPEN_HITMAN_SLOTS, "§eOpen Hitman Slots: §6$openSlotsNow")
put(ChocolateFactoryStat.HITMAN_SLOT_COOLDOWN, "§eHitman Slot Cooldown: §b$hitmanSingleSlotCd")
put(ChocolateFactoryStat.HITMAN_ALL_SLOTS, "§eAll Hitman Slots Cooldown: §b$hitmanAllSlotsCd")

if (HoppityAPI.isHoppityEvent()) {
put(ChocolateFactoryStat.HITMAN_FULL_SLOTS, "§eFull Hitman Slots: §b$hitmanSlotsFull")
put(ChocolateFactoryStat.HITMAN_28_SLOTS, "§e$purchasedSlots Hitman Claims: $hitmanAllClaimReady")
}
}
val text = config.statsDisplayList.filter { it.shouldDisplay() }.flatMap { map[it]?.split("\n").orEmpty() }

Expand Down Expand Up @@ -199,9 +232,13 @@ object ChocolateFactoryStats {
"§eBest Upgrade: §b 59m 4s",
{ ChocolateFactoryAPI.profileStorage?.bestUpgradeCost != 0L },
),
AVAILABLE_HITMAN_EGGS("§eAvailable Hitman Eggs: §b3"),
HITMAN_SLOT_COOLDOWN("§Hitman Slot Cooldown: §b8m 6s"),
HITMAN_HEADER("§c§lRabbit Hitman"),
AVAILABLE_HITMAN_EGGS("§eAvailable Hitman Eggs: §63"),
OPEN_HITMAN_SLOTS("§eOpen Hitman Slots: §63"),
HITMAN_SLOT_COOLDOWN("§eHitman Slot Cooldown: §b8m 6s"),
HITMAN_ALL_SLOTS("§eAll Hitman Slots Cooldown: §b8h 8m 6s"),
HITMAN_FULL_SLOTS("§eFull Hitman Slots: §b2h 10m"),
HITMAN_28_SLOTS("§e28 Hitman Claims: §b3h 20m"),
;

override fun toString(): String {
Expand Down
Loading
Loading