xpIntoLevelForTotalXp function
XP progress within the current level at totalXp — always 0 once the
max level is reached.
Implementation
int xpIntoLevelForTotalXp(List<LevelDefinition> curve, int totalXp) {
var remaining = totalXp;
for (final def in curve) {
if (def.xpToNext == 0) return 0;
if (remaining < def.xpToNext) return remaining;
remaining -= def.xpToNext;
}
return 0;
}