feat: Make use of bazaar stocks for better bazaar prices

This commit is contained in:
Linnea Gräf
2025-06-26 21:22:41 +02:00
parent 04fd3b66df
commit e5ff77c47f
7 changed files with 18 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ enum class BazaarPriceStrategy {
NPC_SELL;
fun getSellPrice(skyblockId: SkyblockId): Double {
val bazaarEntry = HypixelStaticData.bazaarData[skyblockId] ?: return 0.0
val bazaarEntry = HypixelStaticData.bazaarData[skyblockId.asBazaarStock] ?: return 0.0
return when (this) {
BUY_ORDER -> bazaarEntry.quickStatus.sellPrice
SELL_ORDER -> bazaarEntry.quickStatus.buyPrice

View File

@@ -29,6 +29,7 @@ import net.minecraft.util.Identifier
import moe.nea.firmament.repo.ExpLadders
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.repo.set
import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.json.DashlessUUIDSerializer
@@ -69,11 +70,10 @@ value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
@JvmInline
@Serializable
value class BazaarStock(val bazaarId: String) {
fun toRepoId(): SkyblockId {
bazaarEnchantmentRegex.matchEntire(bazaarId)?.let {
return SkyblockId("${it.groupValues[1]};${it.groupValues[2]}")
companion object {
fun fromSkyBlockId(skyblockId: SkyblockId): BazaarStock {
return BazaarStock(RepoManager.neuRepo.constants.bazaarStocks.getBazaarStockOrDefault(skyblockId.neuItem))
}
return SkyblockId(bazaarId.replace(":", "-"))
}
}
@@ -92,6 +92,7 @@ value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
val NEUItem.skyblockId get() = SkyblockId(skyblockItemId)
val NEUIngredient.skyblockId get() = SkyblockId(itemId)
val SkyblockId.asBazaarStock get() = SkyblockId.BazaarStock.fromSkyBlockId(this)
@ExpensiveItemCacheApi
fun NEUItem.guessRecipeId(): String? {