mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
14 lines
428 B
JavaScript
14 lines
428 B
JavaScript
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;
|
|
};
|