fix(api): correct world, cap level

This commit is contained in:
Sabe Jones
2021-03-10 15:36:17 -06:00
parent e3757994b9
commit 96492e5a0e
4 changed files with 12 additions and 3 deletions

View File

@@ -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;

View File

@@ -29,7 +29,7 @@ api.getWorldState = {
const worldState = {};
worldState.worldBoss = await getWorldBoss();
worldState.npcImageSuffix = 'spring';
worldState.npcImageSuffix = '';
worldState.currentEvent = getCurrentEvent();

View File

@@ -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 }));
}

View File

@@ -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: {