rt4-client/plugin-playground/src/main/kotlin/KondoKit/util/XPTable.kt
2025-11-23 05:15:19 -08:00

28 lines
725 B
Kotlin

package KondoKit.util
object XPTable {
private val xpForLevels: IntArray = IntArray(100)
init {
var points = 0.0
for (level in 1..99) {
points += Math.floor(level + 300.0 * Math.pow(2.0, level / 7.0))
xpForLevels[level] = Math.floor(points / 4).toInt()
}
}
fun getLevelForXp(xp: Int): Pair<Int, Int> {
for (i in 1..99) {
if (xp < xpForLevels[i]) {
return Pair(i - 1, xp - xpForLevels[i - 1])
}
}
return Pair(99, 0)
}
fun getXpRequiredForLevel(level: Int): Int {
if (level <= 0) return 0
if (level >= 99) return xpForLevels[99]
return xpForLevels[level]
}
}