mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Implement new release schedule for backgrounds
This commit is contained in:
committed by
Sabe Jones
parent
278d9b74f9
commit
17db6a1772
@@ -5,7 +5,6 @@ import {
|
||||
|
||||
import { assembleScheduledMatchers } from '../../website/common/script/content/constants/schedule';
|
||||
|
||||
|
||||
describe('Content Schedule', () => {
|
||||
it('assembles scheduled items on january 15th', () => {
|
||||
const items = assembleScheduledMatchers(new Date('2024-01-15'));
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"userItemsNotEnough": "You do not have enough <%= type %>",
|
||||
"pathRequired": "Path string is required",
|
||||
"unlocked": "Items have been unlocked",
|
||||
"notAvailable": "This item is not available.",
|
||||
"alreadyUnlocked": "Full set already unlocked.",
|
||||
"alreadyUnlockedPart": "Full set already partially unlocked. It is cheaper to buy the remaining items individually.",
|
||||
"invalidUnlockSet": "This set of items is invalid and cannot be unlocked.",
|
||||
|
||||
@@ -17,6 +17,7 @@ import featuredItems from '../content/shop-featuredItems';
|
||||
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
import { getClassName } from './getClassName';
|
||||
import { assembleScheduledMatchers } from '../content/constants/schedule';
|
||||
|
||||
const shops = {};
|
||||
|
||||
@@ -529,7 +530,9 @@ shops.getBackgroundShopSets = function getBackgroundShopSets (language) {
|
||||
const sets = [];
|
||||
const officialPinnedItems = getOfficialPinnedItems();
|
||||
|
||||
const matchers = assembleScheduledMatchers(new Date()).filter(matcher => matcher.type === 'backgrounds').map(matcher => matcher.matcher);
|
||||
eachRight(content.backgrounds, (group, key) => {
|
||||
if (matchers.map(matcher => matcher(key)).every(matcher => matcher === true)) {
|
||||
const set = {
|
||||
identifier: key,
|
||||
text: i18n.t(key, language),
|
||||
@@ -538,6 +541,7 @@ shops.getBackgroundShopSets = function getBackgroundShopSets (language) {
|
||||
set.items = map(group, background => getItemInfo(null, 'background', background, officialPinnedItems, language));
|
||||
|
||||
sets.push(set);
|
||||
}
|
||||
});
|
||||
|
||||
return sets;
|
||||
|
||||
@@ -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