Skip to content

Commit

Permalink
Show accurate XP gain in notification on level up (#10590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsnael authored and paglias committed Aug 12, 2018
1 parent 45ca090 commit 1f7dd42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion website/client/components/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import axios from 'axios';
import moment from 'moment';
import throttle from 'lodash/throttle';
import { toNextLevel } from '../../common/script/statHelpers';
import { shouldDo } from '../../common/script/cron';
import { mapState } from 'client/libs/store';
import notifications from 'client/mixins/notifications';
Expand Down Expand Up @@ -222,7 +223,12 @@ export default {
userExp (after, before) {
if (after === before) return;
if (this.user.stats.lvl === 0) return;
this.exp(after - before);
let exp = after - before;
if (exp < -50) { // recalculate exp if user level up
exp = toNextLevel(this.user.stats.lvl - 1) - before + after;
}
this.exp(exp);
},
userGp (after, before) {
if (after === before) return;
Expand Down
2 changes: 1 addition & 1 deletion website/client/libs/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ export function round (number, nDigits) {
}

export function getXPMessage (val) {
if (val < -50) return; // don't show when they level up (resetting their exp)
if (val < -50) return; // don't show when they multi-level up (resetting their exp)
return `${getSign(val)} ${round(val)}`;
}

0 comments on commit 1f7dd42

Please sign in to comment.