Fixator10-Cogs icon indicating copy to clipboard operation
Fixator10-Cogs copied to clipboard

[Leveler] XP bar on the profile card is wrong

Open zawnk opened this issue 5 years ago • 6 comments

Describe the bug I've just done the math and was wondering why the leaderboard with ?top says I have less XP than I should have by accumulating the values of the past levels shown on the profile card shown with ?profile. I couldn't wrap my head around it until I've tried around with some users. Seems like the XP required shown in the XP bar in the profile is calculated here:

https://github.com/fixator10/Fixator10-Cogs/blob/b96ff1fe64763eae14194c26ecd84a8b10e059f8/leveler/leveler.py#L3620

But the top leaderboard and the XP that actually leads to levelups uses this formula:

https://github.com/fixator10/Fixator10-Cogs/blob/b96ff1fe64763eae14194c26ecd84a8b10e059f8/leveler/leveler.py#L3623

One example: the profile card said the user is Level 3 and at 468/621 XP to level up. But when I did check the leaderboard, it said they had 1080 points. I used the second formula to calculate that they needed 1094 XP to level up. So 14 XP more, not 153 XP like their profile said. They wrote a message, it gave 17 XP and they leveled up. The leaderboard showed 1097 points and their profile said Level 4 and 3/760 XP. the 760 needed is of course incorrect again. From 4 to 5 you need 621 XP to level up, not 760 (as calculated via the second formula). I've plotted the actual values in this pastebin. The "earned" value is interesting for the leaderboards. I assume that the XP required is calculated by the wrong formula here:

https://github.com/fixator10/Fixator10-Cogs/blob/b96ff1fe64763eae14194c26ecd84a8b10e059f8/leveler/leveler.py#L3022

I think you just need to use the second formula and subtract the overall XP for the next level from the overall XP of the current level. My guess could be wrong, though.

To Reproduce Chat until ?top says you're less than 20 XP away to a level up according to a value in the pastebin, e.g. 269 XP for level 2. Do ?profile and see how it says you need more than 20 XP for the level up. Write a message that yields XP. Check ?profile again and see that you've gained a level up.

Expected behavior The profile exp total for the level should be correct, for example with the formula mentioned above.

Bot's logs No error or anything.

Red version v3.4.0

Additional context n/a

zawnk avatar Aug 27 '20 00:08 zawnk

[p]top by default shows current server (without -global argument). [p]profile shows global stats, for server's stats there is [p]rank

Can you check the same with [p]top -global (or [p]top -g if you are on "rewrite" branch) and [p]profile?

fixator10 avatar Aug 27 '20 06:08 fixator10

Thanks for getting back to me so quickly :) ?top and ?top -global look identical on my server (as in same users with same points). But one says Global Exp Leaderboard and one says Exp Leaderboard, so they're different commands. Maybe the XP shown for ?profile is correct but then I guess ?top shows something incorrect.

I'm running a the bot only on one server, if that matters.

zawnk avatar Aug 27 '20 07:08 zawnk

I think, i fixed it, is this seems ok to you? Before lvlup: img Leveled up: img

fixator10 avatar Aug 27 '20 08:08 fixator10

Yep, that matches the numbers! Because when I check the profile of somebody with level 3 currently, ?profile shows me "x/621", but that's the XP required for level 4 to 5.

Thanks :)

Will the change just be pushed or do you gather commits to a big(ger) relase? You can also ping me on Discord in the RedBot server, once this fix is out (zonk there).

zawnk avatar Aug 27 '20 08:08 zawnk

If you want, you can switch to V3.leveler_abc branch right now, but if you do, i suggest you to backup your mongodb before that. im still not sure how leveler is stable in general.

fixator10 avatar Aug 27 '20 08:08 fixator10

Thanks for the info :) If it might be unstable, I think I'll wait a bit. None of the bugs I've reported are super urgent currently.

zawnk avatar Aug 27 '20 09:08 zawnk