Closed thomas-holmes closed 6 years ago
Thanks for reporting the issue. Do you happen to know what you were doing when you leveled-up? There's somewhat of a bug that I discovered a while back where it wasn't giving the right experience that I had intended, and I've fixed that in my most recent feature branch. In the production env, experience is gained (oddly) from the damage you dealt when you killed an enemy. So say the killing blow was a 40 damage hit, you get 40 experience. My intent (and the updated version) now properly gives you a fraction of the enemy's max HP as experience.
I'm not at which level up the issue started, but I observed it consistently on level up once it happened. I killed things with sword, magic, and bow/arrow.
So I poked around in the code a bit and I believe I've found out where the problem is. It looks like you're computing this in terms of total exp instead of in terms of a specific level. Because each level's total exp cost is 50% greater than the previous that leads to each new level starting at exactly 2/3 complete (plus a little overflow from the previous level).
Without any other refactoring, the math should probably should be more like
let costOfLevel = xp_levels[this.getLevel()+1] - xp_levels[this.getLevel()]
let experienceTowardsNext = costOfLevel - this.getRemainingXP();
return experienceTowardsNext / costOfLevel;
Thanks for checking that out - I think you're exactly right. I'll fix that 👍
I just leveled up but the green progress indicator is 2/3 full.