diff --git a/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt b/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt index ff6ddd4..90cb88a 100644 --- a/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt +++ b/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt @@ -27,6 +27,10 @@ object XPTable { var lowIndex = 0 var highIndex = xpTable.size - 1 + if (xp >= xpTable[highIndex]) { + return Pair(Constants.MAX_LEVEL, xp - xpTable[highIndex]) // Level is max or above, return the highest level + } + while (lowIndex <= highIndex) { val midIndex = (lowIndex + highIndex) / 2 when { @@ -40,6 +44,7 @@ object XPTable { } } - return Pair(Constants.INVALID_LEVEL, 0) // If xp is above all defined levels + return Pair(Constants.INVALID_LEVEL, 0) // If xp is below all defined levels } + }