mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
event code cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import each from 'lodash/each';
|
||||
import defaults from 'lodash/defaults';
|
||||
import moment from 'moment';
|
||||
|
||||
import {
|
||||
CLASSES,
|
||||
@@ -56,22 +55,6 @@ each(GEAR_TYPES, type => {
|
||||
canBuy: () => false,
|
||||
});
|
||||
|
||||
if (item.event) {
|
||||
const canOwnFuncTrue = () => true;
|
||||
const _canOwn = item.canOwn || canOwnFuncTrue;
|
||||
|
||||
item.canOwn = user => {
|
||||
const userHasOwnedItem = ownsItem(key)(user);
|
||||
const eventIsCurrent = moment()
|
||||
.isAfter(item.event.start) && moment().isBefore(item.event.end);
|
||||
const compatibleWithUserClass = item.specialClass
|
||||
? user.stats.class === item.specialClass
|
||||
: true;
|
||||
|
||||
return _canOwn(user) && (userHasOwnedItem || eventIsCurrent) && compatibleWithUserClass;
|
||||
};
|
||||
}
|
||||
|
||||
if (item.mystery || key.indexOf('takeThis') !== -1) {
|
||||
item.canOwn = ownsItem(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user