mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
Implement new release schedule for backgrounds
This commit is contained in:
committed by
Sabe Jones
parent
278d9b74f9
commit
17db6a1772
@@ -7,6 +7,7 @@ import { removeItemByPath } from './pinnedGearUtils';
|
||||
import getItemInfo from '../libs/getItemInfo';
|
||||
import content from '../content/index';
|
||||
import updateUserBalance from './updateUserBalance';
|
||||
import { assembleScheduledMatchers } from '../content/constants/schedule';
|
||||
|
||||
const incentiveBackgrounds = ['blue', 'green', 'red', 'purple', 'yellow'];
|
||||
|
||||
@@ -223,6 +224,17 @@ export default async function unlock (user, req = {}, analytics) {
|
||||
// The passed paths are not used anymore after this point for full sets
|
||||
const { set, items, paths } = getSet(setType, firstPath, req);
|
||||
|
||||
if (isBackground) {
|
||||
const matchers = assembleScheduledMatchers(new Date())
|
||||
.filter(matcher => matcher.type === 'backgrounds')
|
||||
.map(matcher => matcher.matcher);
|
||||
const isAvailable = matchers.map(matcher => matcher(set.key))
|
||||
.every(matcher => matcher === true);
|
||||
if (!isAvailable) {
|
||||
throw new NotAuthorized(i18n.t('notAvailable', req.language));
|
||||
}
|
||||
}
|
||||
|
||||
let cost;
|
||||
let unlockedAlready = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user