Skip to content

Commit

Permalink
Fix: Update Ghost Bestiary Tiers (#2533)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
qtlunya and hannibal002 authored Sep 18, 2024
1 parent a7f0634 commit 50cbf42
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {

val logger = LorenzLogger("ConfigMigration")
const val CONFIG_VERSION = 57
const val CONFIG_VERSION = 58
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class BestiaryFormattingConfig {
@ConfigOption(name = "Progress to Max", desc = "Text to show progress when the §eMaxed Bestiary §7option is §aON\n" +
"§e%currentKill% §7is replaced with your current total kill.")
@ConfigEditorText
public String showMax_progress = "%currentKill%/250k (%percentNumber%%)";
public String showMax_progress = "%currentKill%/100k (%percentNumber%%)";

@Expose
@ConfigOption(name = "Progress", desc = "Text to show progress when the §eMaxed Bestiary §7option is §cOFF\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonPrimitive
import io.github.moulberry.notenoughupdates.util.Utils
import io.github.moulberry.notenoughupdates.util.XPInformation
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand All @@ -76,27 +77,27 @@ object GhostCounter {
private val patternGroup = RepoPattern.group("combat.ghostcounter")
private val skillXPPattern by patternGroup.pattern(
"skillxp",
"[+](?<gained>[0-9,.]+) \\((?<current>[0-9,.]+)(?:/(?<total>[0-9,.]+))?\\)"
"[+](?<gained>[0-9,.]+) \\((?<current>[0-9,.]+)(?:/(?<total>[0-9,.]+))?\\)",
)
private val combatSectionPattern by patternGroup.pattern(
"combatsection",
".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*"
".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*",
)
private val killComboExpiredPattern by patternGroup.pattern(
"killcomboexpired",
"§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!"
"§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!",
)
private val ghostXPPattern by patternGroup.pattern(
"ghostxp",
"(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)"
"(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)",
)
private val bestiaryPattern by patternGroup.pattern(
"bestiary",
".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*"
".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*",
)
private val skillLevelPattern by patternGroup.pattern(
"skilllevel",
".*§e§lSkills: §r§a(?<skillName>.*) (?<skillLevel>\\d+).*"
".*§e§lSkills: §r§a(?<skillName>.*) (?<skillLevel>\\d+).*",
)

private val format = NumberFormat.getInstance()
Expand Down Expand Up @@ -127,7 +128,7 @@ object GhostCounter {
config.position.renderStringsAndItems(
display,
extraSpace = config.extraSpace,
posLabel = "Ghost Counter"
posLabel = "Ghost Counter",
)
}

Expand Down Expand Up @@ -205,7 +206,7 @@ object GhostCounter {

val etaFormatting = textFormatting.etaFormatting
val remaining: Int = when (config.showMax) {
true -> 250_000 - bestiaryCurrentKill
true -> 100_000 - bestiaryCurrentKill
false -> killNeeded - currentKill
}

Expand All @@ -222,7 +223,7 @@ object GhostCounter {
"%days%" to "days",
"%hours%" to "hours",
"%minutes%" to "minutes",
"%seconds%" to "seconds"
"%seconds%" to "seconds",
)
for ((format, key) in formatMap) {
if (etaFormatting.time.contains(format)) {
Expand Down Expand Up @@ -255,8 +256,7 @@ object GhostCounter {
addAsSingletonList(textFormatting.highestKillComboFormat.formatText(Option.MAXKILLCOMBO))
addAsSingletonList(textFormatting.skillXPGainFormat.formatText(Option.SKILLXPGAINED))
addAsSingletonList(
bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel)
.formatBestiary(currentKill, killNeeded)
bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel).formatBestiary(currentKill, killNeeded),
)

addAsSingletonList(xpHourFormatting.base.formatText(xp))
Expand All @@ -275,7 +275,7 @@ object GhostCounter {
Triple("Volta", Option.VOLTACOUNT.getInt(), voltaValue),
Triple("Bag Of Cash", Option.BAGOFCASH.getInt(), 1_000_000),
Triple("Scavenger Coins", Option.SCAVENGERCOINS.getInt(), 1),
Triple("Ghostly Boots", Option.GHOSTLYBOOTS.getInt(), 77_777)
Triple("Ghostly Boots", Option.GHOSTLYBOOTS.getInt(), 77_777),
)
val moneyMadeTips = buildList {
for ((name, count, value) in priceMap) {
Expand All @@ -288,7 +288,7 @@ object GhostCounter {
val moneyMadeWithClickableTips = Renderable.clickAndHover(
textFormatting.moneyMadeFormat.formatText(moneyMade.addSeparators()),
moneyMadeTips,
onClick = { OSUtils.copyToClipboard(moneyMadeTips.joinToString("\n").removeColor()) }
onClick = { OSUtils.copyToClipboard(moneyMadeTips.joinToString("\n").removeColor()) },
)
addAsSingletonList(textFormatting.moneyHourFormat.formatText(final))
addAsSingletonList(moneyMadeWithClickableTips)
Expand Down Expand Up @@ -327,7 +327,7 @@ object GhostCounter {
},
"§eClick to import data!",
prefixColor = "§6",
oneTimeClick = true
oneTimeClick = true,
)
}
}
Expand Down Expand Up @@ -365,9 +365,8 @@ object GhostCounter {
var parse = true
if (skillPercent) {
percent = nf.parse(group("percent")).toFloat()
val level =
if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance()
.getSkillInfo(skillName)?.level ?: 0
val level = if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance()
.getSkillInfo(skillName)?.level ?: 0
if (level > 0) {
totalSkillXp = SkillExperience.getExpForNextLevel(level)
currentSkillXp = totalSkillXp * percent / 100
Expand Down Expand Up @@ -419,11 +418,10 @@ object GhostCounter {
Option.SORROWCOUNT, Option.VOLTACOUNT, Option.PLASMACOUNT, Option.GHOSTLYBOOTS -> {
opt.add(1.0)
opt.add(1.0, true)
storage?.totalMF = storage?.totalMF?.plus(group("mf").substring(4).toDouble())
?: group("mf").substring(4).toDouble()
storage?.totalMF =
storage?.totalMF?.plus(group("mf").substring(4).toDouble()) ?: group("mf").substring(4).toDouble()
Option.TOTALDROPS.add(1.0)
if (opt == Option.SORROWCOUNT)
Option.GHOSTSINCESORROW.set(0.0)
if (opt == Option.SORROWCOUNT) Option.GHOSTSINCESORROW.set(0.0)
update()
}

Expand Down Expand Up @@ -459,7 +457,7 @@ object GhostCounter {
when (val nextLevel = if (currentLevel >= 25) 26 else currentLevel + 1) {
26 -> {
storage?.bestiaryNextLevel = 26.0
storage?.bestiaryCurrentKill = 250_000.0
storage?.bestiaryCurrentKill = 100_000.0
storage?.bestiaryKillNeeded = 0.0
}

Expand Down Expand Up @@ -491,8 +489,7 @@ object GhostCounter {
val stacks = event.inventoryItems
val ghostStack = stacks.values.find { it.displayName.contains("Ghost") } ?: return
val bestiaryNextLevel =
if ("§\\wGhost".toRegex().matches(ghostStack.displayName)) 1 else ghostStack.displayName.substring(8)
.romanToDecimal() + 1
if ("§\\wGhost".toRegex().matches(ghostStack.displayName)) 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1
storage?.bestiaryNextLevel = bestiaryNextLevel.toDouble()
var kills = 0.0
for (line in ghostStack.getLore()) {
Expand Down Expand Up @@ -523,6 +520,10 @@ object GhostCounter {
event.transform(11, "combat.ghostCounter.ghostDisplayText") { element ->
ConfigUtils.migrateIntArrayListToEnumArrayList(element, GhostDisplayEntry::class.java)
}

event.transform(58, "combat.ghostCounter.textFormatting.bestiaryFormatting.showMax_progress") {
JsonPrimitive("%currentKill%/100k (%percentNumber%%)")
}
}

fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ object GhostData {
Option.SKILLXPGAINED to 0.0
)

// TODO repo
val bestiaryData = mutableMapOf<Int, Int>().apply {
for (i in 1..25) {
this[i] = when (i) {
1 -> 5
2 -> 5
3 -> 5
4 -> 10
5 -> 25
6 -> 50
7 -> 100
8 -> 150
9 -> 150
10 -> 250
11 -> 750
12 -> 1_500
13 -> 2_000
14, 15, 16, 17 -> 2_500
18 -> 3_000
19, 20 -> 3_500
21 -> 25_000
22, 23, 24, 25 -> 50_000
1, 2, 3, 4, 5 -> 4
6 -> 20
7 -> 40
8, 9 -> 60
10 -> 100
11 -> 300
12 -> 600
13 -> 800
14, 15, 16, 17 -> 1_000
18 -> 1_200
19, 20 -> 1_400
21 -> 10_000
22, 23, 24, 25 -> 20_000
else -> 0
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ object GhostFormatting {
base = " &6Bestiary %currentLevel%->%nextLevel%: &b%value%"
openMenu = "§cOpen Bestiary Menu !"
maxed = "%currentKill% (&c&lMaxed!)"
showMax_progress = "%currentKill%/250k (%percentNumber%%)"
showMax_progress = "%currentKill%/100k (%percentNumber%%)"
progress = "%currentKill%/%killNeeded%"
}
with(killHourFormatting) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ object GhostUtil {
}

private fun percent(number: Double) =
100.0.coerceAtMost(((number / 250_000) * 100).roundToPrecision(4)).toString()
100.0.coerceAtMost(((number / 100_000) * 100).roundToPrecision(4)).toString()
}

0 comments on commit 50cbf42

Please sign in to comment.