mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
limit free rebirth to once every 45 days
This commit is contained in:
@@ -4,6 +4,7 @@ import { BadRequest } from './errors';
|
||||
import count from '../count';
|
||||
|
||||
import isPinned from './isPinned';
|
||||
import isFreeRebirth from './isFreeRebirth';
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
|
||||
import _mapValues from 'lodash/mapValues';
|
||||
@@ -296,7 +297,7 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
class: 'rebirth_orb',
|
||||
text: i18n.t('rebirthName'),
|
||||
notes: i18n.t('rebirthPop'),
|
||||
value: user.stats.lvl < 100 ? 6 : 0,
|
||||
value: isFreeRebirth(user) ? 0 : 6,
|
||||
currency: 'gems',
|
||||
path: 'special.rebirth_orb',
|
||||
pinType: 'rebirth_orb',
|
||||
|
||||
14
website/common/script/libs/isFreeRebirth.js
Normal file
14
website/common/script/libs/isFreeRebirth.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import moment from 'moment';
|
||||
import { MAX_LEVEL } from '../constants';
|
||||
|
||||
module.exports = function isFreeRebirth (user) {
|
||||
let daysFromLastFreeRebirth = user.flags.lastFreeRebirth;
|
||||
|
||||
if (daysFromLastFreeRebirth) {
|
||||
daysFromLastFreeRebirth = moment().diff(moment(user.flags.lastFreeRebirth), 'days');
|
||||
} else {
|
||||
daysFromLastFreeRebirth = 999;
|
||||
}
|
||||
|
||||
return user.stats.lvl >= MAX_LEVEL && daysFromLastFreeRebirth > 45;
|
||||
};
|
||||
Reference in New Issue
Block a user