mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-14 10:30:22 -07:00
fix up remaining spacing issues
This commit is contained in:
parent
3392d61d9e
commit
5bb81c7bd3
39 changed files with 244 additions and 271 deletions
31
plugin-playground/src/main/kotlin/KondoKit/util/XPTable.kt
Normal file
31
plugin-playground/src/main/kotlin/KondoKit/util/XPTable.kt
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package KondoKit.util
|
||||
|
||||
/**
|
||||
* Utility for mapping XP values to levels and vice versa.
|
||||
*/
|
||||
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]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue