mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
limit free rebirth to once every 45 days
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user