Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LevelModule = {}
- function LevelModule:getNeededExp(level)
- return level * 115
- end
- function LevelModule:playerReadyToLevel(stats)
- return stats.exp > stats.neededExp
- end
- function LevelModule:addPlayerExp(stats, amountOfExp)
- stats.exp = stats.exp + amountOfExp
- end
- function LevelModule:levelPlayer(stats)
- self:addPlayerExp(stats, -stats.neededExp)
- self:addPlayerLevel(stats, 1)
- self:setPlayerNeededExp(stats)
- end
- function LevelModule:levelLoop(stats)
- while self:playerReadyToLevel(stats) and not self:isPlayerMaxLevel(stats) do
- self:levelPlayer(stats)
- end
- end
- function LevelModule:clampPlayerExp(stats)
- local neededExp = self:getNeededExp(stats.level)
- stats.exp = math.clamp(stats.exp, 0, neededExp)
- end
- function LevelModule:setPlayerNeededExp(stats)
- stats.neededExp = self:getNeededExp(stats.level)
- end
- function LevelModule:addPlayerLevel(stats, amountOfLevels)
- stats.level = stats.level + amountOfLevels
- end
- function LevelModule:isPlayerMaxLevel(stats)
- return stats.level >= stats.maxLevel
- end
- return LevelModule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement