Larkenx / Rotten-Soup

A roguelike built with Vue, Vuetify, Tiled, rot.js, and PixiJS! Playable at https://rottensoup.herokuapp.com/
GNU General Public License v3.0
385 stars 55 forks source link

EXP Radial computing with total exp rather than level specific xp #24

Closed thomas-holmes closed 6 years ago

thomas-holmes commented 6 years ago

I just leveled up but the green progress indicator is 2/3 full.

image

Larkenx commented 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.

thomas-holmes commented 6 years ago

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).

https://github.com/Larkenx/Rotten-Soup/blob/dbf446c3c4cbbd279a9210333032e3ed4d948bc0/src/components/HUD/StatsTabContent.vue#L85-L88

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;
Larkenx commented 6 years ago

Thanks for checking that out - I think you're exactly right. I'll fix that 👍