Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Leveler] XP bar on the profile card is wrong #45

Open
zawnk opened this issue Aug 27, 2020 · 6 comments
Open

[Leveler] XP bar on the profile card is wrong #45

zawnk opened this issue Aug 27, 2020 · 6 comments
Labels
bug pls fix

Comments

@zawnk
Copy link

zawnk commented Aug 27, 2020

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:

return 139 * level + 65

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

return level * 65 + 139 * level * (level - 1) // 2

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:

exp_total = await self._required_exp(userinfo["servers"][str(server.id)]["level"])

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 zawnk added the bug pls fix label Aug 27, 2020
@fixator10 fixator10 assigned fixator10 and unassigned fixator10 Aug 27, 2020
@fixator10
Copy link
Owner

[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 fixator10 changed the title [Leveler] Bug report: XP bar on the profile card is wrong [Leveler] XP bar on the profile card is wrong Aug 27, 2020
@zawnk
Copy link
Author

zawnk commented Aug 27, 2020

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.

fixator10 added a commit that referenced this issue Aug 27, 2020
@fixator10
Copy link
Owner

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

@zawnk
Copy link
Author

zawnk commented Aug 27, 2020

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

@fixator10
Copy link
Owner

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.

@zawnk
Copy link
Author

zawnk commented Aug 27, 2020

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.

fixator10 added a commit that referenced this issue Oct 16, 2020
i dont know what im doing already, send help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pls fix
Projects
None yet
Development

No branches or pull requests

2 participants