mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fix(api): correct world, cap level
This commit is contained in:
@@ -151,6 +151,8 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.restoreValues.stats.lvl > 999) this.restoreValues.stats.lvl = 999;
|
||||
|
||||
const userChangedLevel = this.restoreValues.stats.lvl !== this.user.stats.lvl;
|
||||
const userDidNotChangeExp = this.restoreValues.stats.exp === this.user.stats.exp;
|
||||
if (userChangedLevel && userDidNotChangeExp) this.restoreValues.stats.exp = 0;
|
||||
|
||||
@@ -29,7 +29,7 @@ api.getWorldState = {
|
||||
const worldState = {};
|
||||
|
||||
worldState.worldBoss = await getWorldBoss();
|
||||
worldState.npcImageSuffix = 'spring';
|
||||
worldState.npcImageSuffix = '';
|
||||
|
||||
worldState.currentEvent = getCurrentEvent();
|
||||
|
||||
|
||||
@@ -166,7 +166,9 @@ export async function update (req, res, { isV3 = false }) {
|
||||
user.flags.lastNewStuffRead = lastNewsPost._id;
|
||||
}
|
||||
} else if (acceptablePUTPaths[key]) {
|
||||
_.set(user, key, val);
|
||||
let adjustedVal = val;
|
||||
if (key === 'stats.lvl' && val > 999) adjustedVal = 999;
|
||||
_.set(user, key, adjustedVal);
|
||||
} else {
|
||||
throw new NotAuthorized(res.t('messageUserOperationProtected', { operation: key }));
|
||||
}
|
||||
|
||||
@@ -592,7 +592,12 @@ export default new Schema({
|
||||
mp: { $type: Number, default: 10 },
|
||||
exp: { $type: Number, default: 0 },
|
||||
gp: { $type: Number, default: 0 },
|
||||
lvl: { $type: Number, default: 1, min: 1 },
|
||||
lvl: {
|
||||
$type: Number,
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: 999,
|
||||
},
|
||||
|
||||
// Class System
|
||||
class: {
|
||||
|
||||
Reference in New Issue
Block a user