mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix(stats): bump level cap to 9999 and related corrections
This commit is contained in:
@@ -115,6 +115,7 @@ import { toNextLevel } from '@/../../common/script/statHelpers';
|
|||||||
import { shouldDo } from '@/../../common/script/cron';
|
import { shouldDo } from '@/../../common/script/cron';
|
||||||
import { onOnboardingComplete } from '@/../../common/script/libs/onboarding';
|
import { onOnboardingComplete } from '@/../../common/script/libs/onboarding';
|
||||||
import { mapState } from '@/libs/store';
|
import { mapState } from '@/libs/store';
|
||||||
|
import { MAX_LEVEL_HARD_CAP } from '@/../../common/script/constants';
|
||||||
import notifications from '@/mixins/notifications';
|
import notifications from '@/mixins/notifications';
|
||||||
import guide from '@/mixins/guide';
|
import guide from '@/mixins/guide';
|
||||||
|
|
||||||
@@ -651,7 +652,7 @@ export default {
|
|||||||
const lvlUps = afterLvl - beforeLvl;
|
const lvlUps = afterLvl - beforeLvl;
|
||||||
let exp = afterExp - beforeExp;
|
let exp = afterExp - beforeExp;
|
||||||
|
|
||||||
if (lvlUps > 0) {
|
if (lvlUps > 0 || afterLvl >= MAX_LEVEL_HARD_CAP) {
|
||||||
let level = Math.trunc(beforeLvl);
|
let level = Math.trunc(beforeLvl);
|
||||||
exp += toNextLevel(level);
|
exp += toNextLevel(level);
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import clone from 'lodash/clone';
|
import clone from 'lodash/clone';
|
||||||
|
import { MAX_LEVEL_HARD_CAP } from '@/../../common/script/constants';
|
||||||
import { mapState } from '@/libs/store';
|
import { mapState } from '@/libs/store';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -151,7 +152,9 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.restoreValues.stats.lvl > 999) this.restoreValues.stats.lvl = 999;
|
if (this.restoreValues.stats.lvl > MAX_LEVEL_HARD_CAP) {
|
||||||
|
this.restoreValues.stats.lvl = MAX_LEVEL_HARD_CAP;
|
||||||
|
}
|
||||||
|
|
||||||
const userChangedLevel = this.restoreValues.stats.lvl !== this.user.stats.lvl;
|
const userChangedLevel = this.restoreValues.stats.lvl !== this.user.stats.lvl;
|
||||||
const userDidNotChangeExp = this.restoreValues.stats.exp === this.user.stats.exp;
|
const userDidNotChangeExp = this.restoreValues.stats.exp === this.user.stats.exp;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export const MAX_HEALTH = 50;
|
export const MAX_HEALTH = 50;
|
||||||
export const MAX_LEVEL = 100;
|
export const MAX_LEVEL = 100;
|
||||||
export const MAX_STAT_POINTS = MAX_LEVEL;
|
export const MAX_STAT_POINTS = MAX_LEVEL;
|
||||||
|
export const MAX_LEVEL_HARD_CAP = 9999;
|
||||||
export const ATTRIBUTES = ['str', 'int', 'con', 'per'];
|
export const ATTRIBUTES = ['str', 'int', 'con', 'per'];
|
||||||
export const MAX_INCENTIVES = 500;
|
export const MAX_INCENTIVES = 500;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import each from 'lodash/each';
|
import each from 'lodash/each';
|
||||||
import {
|
import {
|
||||||
MAX_HEALTH,
|
MAX_HEALTH,
|
||||||
|
MAX_LEVEL_HARD_CAP,
|
||||||
MAX_STAT_POINTS,
|
MAX_STAT_POINTS,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { toNextLevel } from '../statHelpers';
|
import { toNextLevel } from '../statHelpers';
|
||||||
@@ -24,7 +25,11 @@ export default function updateStats (user, stats, req = {}, analytics) {
|
|||||||
|
|
||||||
while (stats.exp >= experienceToNextLevel) {
|
while (stats.exp >= experienceToNextLevel) {
|
||||||
stats.exp -= experienceToNextLevel;
|
stats.exp -= experienceToNextLevel;
|
||||||
user.stats.lvl += 1;
|
if (user.stats.lvl >= MAX_LEVEL_HARD_CAP) {
|
||||||
|
user.stats.lvl = MAX_LEVEL_HARD_CAP;
|
||||||
|
} else {
|
||||||
|
user.stats.lvl += 1;
|
||||||
|
}
|
||||||
|
|
||||||
experienceToNextLevel = toNextLevel(user.stats.lvl);
|
experienceToNextLevel = toNextLevel(user.stats.lvl);
|
||||||
user.stats.hp = MAX_HEALTH;
|
user.stats.hp = MAX_HEALTH;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
MAX_HEALTH,
|
MAX_HEALTH,
|
||||||
MAX_INCENTIVES,
|
MAX_INCENTIVES,
|
||||||
MAX_LEVEL,
|
MAX_LEVEL,
|
||||||
|
MAX_LEVEL_HARD_CAP,
|
||||||
MAX_STAT_POINTS,
|
MAX_STAT_POINTS,
|
||||||
MAX_SUMMARY_SIZE_FOR_CHALLENGES,
|
MAX_SUMMARY_SIZE_FOR_CHALLENGES,
|
||||||
MAX_SUMMARY_SIZE_FOR_GUILDS,
|
MAX_SUMMARY_SIZE_FOR_GUILDS,
|
||||||
@@ -114,6 +115,7 @@ api.constants = {
|
|||||||
MINIMUM_PASSWORD_LENGTH,
|
MINIMUM_PASSWORD_LENGTH,
|
||||||
MAX_MESSAGE_LENGTH,
|
MAX_MESSAGE_LENGTH,
|
||||||
MAX_GIFT_MESSAGE_LENGTH,
|
MAX_GIFT_MESSAGE_LENGTH,
|
||||||
|
MAX_LEVEL_HARD_CAP,
|
||||||
};
|
};
|
||||||
// TODO Move these under api.constants
|
// TODO Move these under api.constants
|
||||||
api.maxLevel = MAX_LEVEL;
|
api.maxLevel = MAX_LEVEL;
|
||||||
|
|||||||
@@ -167,7 +167,9 @@ export async function update (req, res, { isV3 = false }) {
|
|||||||
}
|
}
|
||||||
} else if (acceptablePUTPaths[key]) {
|
} else if (acceptablePUTPaths[key]) {
|
||||||
let adjustedVal = val;
|
let adjustedVal = val;
|
||||||
if (key === 'stats.lvl' && val > 999) adjustedVal = 999;
|
if (key === 'stats.lvl' && val > common.constants.MAX_LEVEL_HARD_CAP) {
|
||||||
|
adjustedVal = common.constants.MAX_LEVEL_HARD_CAP;
|
||||||
|
}
|
||||||
_.set(user, key, adjustedVal);
|
_.set(user, key, adjustedVal);
|
||||||
} else {
|
} else {
|
||||||
throw new NotAuthorized(res.t('messageUserOperationProtected', { operation: key }));
|
throw new NotAuthorized(res.t('messageUserOperationProtected', { operation: key }));
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ export default new Schema({
|
|||||||
$type: Number,
|
$type: Number,
|
||||||
default: 1,
|
default: 1,
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 999,
|
max: shared.constants.MAX_LEVEL_HARD_CAP,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Class System
|
// Class System
|
||||||
|
|||||||
Reference in New Issue
Block a user