I am creating a game with a plethora of skills such as mining, woodcutting, fishing, etc.
I need to calculate the users level based off of a formula. I am using the below code, and I would like to know if you think that it is efficent and will it give me the proper level?
function grabLevel($exp) {
for($level = 1; (pow($level, 3) * 20) < $exp; $level++) {
return $level;
}
}
The experience formula is Level^3 * 20
So level 5 would require 2,500 Experience in that skill. All skills use the same level formula.