event code cleanup

This commit is contained in:
Phillip Thelen
2024-05-14 12:41:49 +02:00
parent efe8cff1ad
commit 5b6cc23fb7
6 changed files with 53 additions and 86 deletions

View File

@@ -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);
}