mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Implement new scheduling for time travelers shop
This commit is contained in:
committed by
Sabe Jones
parent
ce796fa1d9
commit
278d9b74f9
@@ -7,6 +7,7 @@ import moment from 'moment';
|
||||
|
||||
import mysterySets from './mystery-sets';
|
||||
import gear from './gear';
|
||||
import { assembleScheduledMatchers } from './constants/schedule';
|
||||
|
||||
const mystery = mysterySets;
|
||||
|
||||
@@ -17,7 +18,8 @@ each(mystery, (v, k) => {
|
||||
if (v.items.length === 0) delete mystery[k];
|
||||
});
|
||||
|
||||
const timeTravelerStore = user => {
|
||||
const timeTravelerStore = (user, date) => {
|
||||
const availabilityMatchers = assembleScheduledMatchers(date).filter(matcher => matcher.type === 'timeTravelers').map(matcher => matcher.matcher);
|
||||
let ownedKeys;
|
||||
const { owned } = user.items.gear;
|
||||
const { mysteryItems } = user.purchased.plan;
|
||||
@@ -26,13 +28,13 @@ const timeTravelerStore = user => {
|
||||
ownedKeys = union(ownedKeys, unopenedGifts);
|
||||
return reduce(mystery, (m, v, k) => {
|
||||
if (
|
||||
k === 'wondercon'
|
||||
|| ownedKeys.indexOf(v.items[0].key) !== -1
|
||||
|| (moment(k).add(1, 'months').isAfter() && moment(k).isBefore('3000-01-01'))
|
||||
k !== 'wondercon'
|
||||
&& ownedKeys.indexOf(v.items[0].key) === -1
|
||||
&& (moment(k).isAfter('3000-01-01')
|
||||
|| availabilityMatchers.map(matcher => matcher(k)).every(matcher => matcher === true))
|
||||
) {
|
||||
return m;
|
||||
m[k] = v;
|
||||
}
|
||||
m[k] = v;
|
||||
return m;
|
||||
}, {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user