I'm developing a simple text battle game and having some issues calculating how much XP should be earned after a battle, theres a few factors that i want to consider:
1) Players should of course earn good XP if they beat someone of the same level
2) Players should earn great XP if they beat someone of a higher level
3) Players should earn poor XP if they defeat someone of a lower level
4) The above should scale nicely, i.e. if player A is level 10 and battles Player B who's level 9 or 11 the difference shouldn't be huge (they would of course gain more XP for defeating the level 11 character but we wouldn't expect this to be huge), but if he was to battle a level 5 or 15 this difference should be huge.
Just having trouble calculating something that works well in all scenarios, currently my XP table looks like the below:
Current Level XP Needed Increase from Last Level 1 30 0 2 65 35 3 106 41 4 154 48 5 210 56 ... 10 672 123
In PHP my code looks like the below to calculate the XP Needed:
$offset = 30; $multiplier = 1.17; $base = $prevXp * $multiplier; $xp = $base + $offset;
I've tried a few different things but i haven't been impressed with any of them, I'd like to work with calculating the difference in XP and then using some kind of multiplier but i haven't been impressed with the results.
Any help / input would be appreciated.