limit free rebirth to once every 45 days

This commit is contained in:
Matteo Pagliazzi
2019-06-17 20:37:18 +02:00
parent f987585cf1
commit 2cbb0a85a4
4 changed files with 26 additions and 4 deletions

View File

@@ -7,12 +7,14 @@ import {
} from '../libs/errors';
import equip from './equip';
import { removePinnedGearByClass } from './pinnedGearUtils';
import isFreeRebirth from '../libs/isFreeRebirth';
const USERSTATSLIST = ['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'];
module.exports = function rebirth (user, tasks = [], req = {}, analytics) {
if (user.balance < 1.5 && user.stats.lvl < MAX_LEVEL) {
const notFree = !isFreeRebirth(user);
if (user.balance < 1.5 && notFree) {
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
}
@@ -21,7 +23,7 @@ module.exports = function rebirth (user, tasks = [], req = {}, analytics) {
category: 'behavior',
};
if (user.stats.lvl < MAX_LEVEL) {
if (notFree) {
user.balance -= 1.5;
analyticsData.acquireMethod = 'Gems';
analyticsData.gemCost = 6;
@@ -95,6 +97,10 @@ module.exports = function rebirth (user, tasks = [], req = {}, analytics) {
user.achievements.rebirthLevel = lvl;
}
if (!notFree) {
user.flags.lastFreeRebirth = new Date();
}
if (user.addNotification) user.addNotification('REBIRTH_ACHIEVEMENT');
user.stats.buffs = {};