OK, using the answers over at this question I was able to produce the following code to calculated the experience needed to level on a text-based RPG I am working on. I'll say from the get-go that my math skills are not great, so please "dumb it down" as much as you can.
function calcExp($L) {
if($L <= 5) {
//If Level 5 or less then just 12 exp per level
return 12*$L;
}
if($L > 1000) {
//If over level 1,000, we need to slow them down
//add an additional 500k per level required
$calc = $L - 1000;
$c2 = 500000*$calc;
return (5*$L*$L-5*$L)+$c2;
}
else {
//otherwise, calculate as follows
$exp = 5 * $L * $L - 5 * $L;
return $exp;
}
}
That returns the correct amount of experience, now I'm trying to figure out how to reverse the process so that I can checkLvl($EXPERIENCE)
and have it return the level it should be at.
So then if I were to
$level = 10;
$exp = 450;
$check = checkLvl($exp);
if($check != $level) { die('Unknown Error'); }
else { echo "Success!"; }
Note: the above code is just me trying to be clear.
I'm at a loss as to how to reverse the little mess I created.