Add , seperatation to currency information
This commit is contained in:
@@ -83,7 +83,7 @@ fun firmamentCommand() = literal("firmament") {
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
"firmament.price.bazaar.buy.price",
|
||||
FirmFormatters.toString(bazaarData.quickStatus.buyPrice, 1)
|
||||
FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1)
|
||||
)
|
||||
)
|
||||
source.sendFeedback(
|
||||
@@ -95,7 +95,7 @@ fun firmamentCommand() = literal("firmament") {
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
"firmament.price.bazaar.sell.price",
|
||||
FirmFormatters.toString(bazaarData.quickStatus.sellPrice, 1)
|
||||
FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1)
|
||||
)
|
||||
)
|
||||
source.sendFeedback(
|
||||
@@ -110,7 +110,7 @@ fun firmamentCommand() = literal("firmament") {
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
"firmament.price.lowestbin",
|
||||
FirmFormatters.toString(lowestBin, 1)
|
||||
FirmFormatters.formatCurrency(lowestBin, 1)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ object PriceData : FirmamentFeature {
|
||||
it.lines.add(
|
||||
Text.translatable(
|
||||
"firmament.tooltip.bazaar.sell-order",
|
||||
FirmFormatters.toString(bazaarData.quickStatus.sellPrice, 1)
|
||||
FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1)
|
||||
)
|
||||
)
|
||||
it.lines.add(
|
||||
Text.translatable(
|
||||
"firmament.tooltip.bazaar.buy-order",
|
||||
FirmFormatters.toString(bazaarData.quickStatus.buyPrice, 1)
|
||||
FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1)
|
||||
)
|
||||
)
|
||||
} else if (lowestBin != null) {
|
||||
@@ -52,7 +52,7 @@ object PriceData : FirmamentFeature {
|
||||
it.lines.add(
|
||||
Text.translatable(
|
||||
"firmament.tooltip.ah.lowestbin",
|
||||
FirmFormatters.toString(lowestBin, 1)
|
||||
FirmFormatters.formatCurrency(lowestBin, 1)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ object PetsPage : ProfilePage {
|
||||
Text.literal("Magic Find: ").styled { it.withColor(Formatting.AQUA) }
|
||||
.append(
|
||||
Text.literal(
|
||||
FirmFormatters.toString(
|
||||
FirmFormatters.formatCurrency(
|
||||
RepoManager.neuRepo.constants.bonuses.getPetRewards(
|
||||
petScore
|
||||
)["magic_find"] ?: 0.0F, 1
|
||||
|
||||
@@ -49,7 +49,7 @@ object SkillPage : ProfilePage {
|
||||
) {
|
||||
override fun addTooltip(tooltip: TooltipBuilder) {
|
||||
tooltip.add(Text.literal("$level/$maxLevel"))
|
||||
tooltip.add(Text.translatable("firmament.pv.skills.total", FirmFormatters.toString(exp, 1)))
|
||||
tooltip.add(Text.translatable("firmament.pv.skills.total", FirmFormatters.formatCurrency(exp, 1)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,10 @@ data class SBItemStack(
|
||||
?.interpolatedStatsAtLevel(petData.levelData.currentLevel)
|
||||
if (stats != null) {
|
||||
stats.otherNumbers.forEachIndexed { index, it ->
|
||||
replacementData[index.toString()] = FirmFormatters.toString(it, 1)
|
||||
replacementData[index.toString()] = FirmFormatters.formatCurrency(it, 1)
|
||||
}
|
||||
stats.statNumbers.forEach { (t, u) ->
|
||||
replacementData[t] = FirmFormatters.toString(u, 1)
|
||||
replacementData[t] = FirmFormatters.formatCurrency(u, 1)
|
||||
}
|
||||
}
|
||||
replacementData["LVL"] = petData.levelData.currentLevel.toString()
|
||||
|
||||
@@ -11,13 +11,21 @@ import kotlin.math.absoluteValue
|
||||
import kotlin.time.Duration
|
||||
|
||||
object FirmFormatters {
|
||||
fun toString(float: Float, fractionalDigits: Int): String = toString(float.toDouble(), fractionalDigits)
|
||||
fun toString(double: Double, fractionalDigits: Int): String {
|
||||
fun formatCurrency(long: Long, segments: Int = 3): String {
|
||||
val α = long / 1000
|
||||
if (α != 0L) {
|
||||
return formatCurrency(α, segments) + "," + (long - α * 1000).toString().padStart(3, '0')
|
||||
}
|
||||
return long.toString()
|
||||
}
|
||||
|
||||
fun formatCurrency(float: Float, fractionalDigits: Int): String = formatCurrency(float.toDouble(), fractionalDigits)
|
||||
fun formatCurrency(double: Double, fractionalDigits: Int): String {
|
||||
val long = double.toLong()
|
||||
val δ = (double - long).absoluteValue
|
||||
val μ = pow(10, fractionalDigits)
|
||||
val digits = (μ * δ).toInt().toString().padStart(fractionalDigits, '0').trimEnd('0')
|
||||
return long.toString() + (if (digits.isEmpty()) "" else ".$digits")
|
||||
return formatCurrency(long) + (if (digits.isEmpty()) "" else ".$digits")
|
||||
}
|
||||
|
||||
fun formatTimespan(duration: Duration): String {
|
||||
|
||||
Reference in New Issue
Block a user