mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
display customizations in new shop
This commit is contained in:
committed by
Sabe Jones
parent
982069df36
commit
f99ddbe60f
@@ -3,7 +3,6 @@ import SEASONAL_SETS from './seasonalSets';
|
||||
|
||||
function backgroundMatcher (month1, month2, oddYear) {
|
||||
return function call (key) {
|
||||
if (!key.startsWith('backgrounds')) return true;
|
||||
const keyLength = key.length;
|
||||
const month = parseInt(key.substring(keyLength - 6, keyLength - 4), 10);
|
||||
return (month === month1 || month === month2)
|
||||
@@ -24,6 +23,26 @@ function inListMatcher (list) {
|
||||
};
|
||||
}
|
||||
|
||||
const ALWAYS_AVAILABLE_CUSTOMIZATIONS = [
|
||||
'animalSkins',
|
||||
'rainbowSkins',
|
||||
'rainbowHairColors',
|
||||
'specialShirts',
|
||||
'facialHair',
|
||||
'baseHair1',
|
||||
'baseHair2',
|
||||
'baseHair3',
|
||||
];
|
||||
|
||||
function customizationMatcher (list) {
|
||||
return function call (item) {
|
||||
if (ALWAYS_AVAILABLE_CUSTOMIZATIONS.indexOf(item) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return list.indexOf(item) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
export const FIRST_RELEASE_DAY = 1;
|
||||
export const SECOND_RELEASE_DAY = 7;
|
||||
export const THIRD_RELEASE_DAY = 14;
|
||||
@@ -601,6 +620,12 @@ export const MONTHLY_SCHEDULE = {
|
||||
};
|
||||
|
||||
export const GALA_SWITCHOVER_DAY = 21;
|
||||
export const GALA_KEYS = [
|
||||
'winter',
|
||||
'spring',
|
||||
'summer',
|
||||
'fall',
|
||||
];
|
||||
export const GALA_SCHEDULE = {
|
||||
0: [
|
||||
{
|
||||
@@ -620,6 +645,13 @@ export const GALA_SCHEDULE = {
|
||||
'evilsanta2',
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'customizations',
|
||||
matcher: customizationMatcher([
|
||||
'winteryHairColors',
|
||||
'winterySkins',
|
||||
]),
|
||||
},
|
||||
],
|
||||
1: [
|
||||
{
|
||||
@@ -632,20 +664,15 @@ export const GALA_SCHEDULE = {
|
||||
'shinySeed',
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'customizations',
|
||||
matcher: customizationMatcher([
|
||||
'shimmerHairColors',
|
||||
'pastelSkins',
|
||||
]),
|
||||
},
|
||||
],
|
||||
2: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.fall,
|
||||
},
|
||||
{
|
||||
type: 'seasonalSpells',
|
||||
items: [
|
||||
'spookySparkles',
|
||||
],
|
||||
},
|
||||
],
|
||||
3: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.summer,
|
||||
@@ -656,9 +683,45 @@ export const GALA_SCHEDULE = {
|
||||
'seafoam',
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'customizations',
|
||||
matcher: customizationMatcher([
|
||||
'splashySkins',
|
||||
]),
|
||||
},
|
||||
],
|
||||
3: [
|
||||
{
|
||||
type: 'seasonalGear',
|
||||
items: SEASONAL_SETS.fall,
|
||||
},
|
||||
{
|
||||
type: 'seasonalSpells',
|
||||
items: [
|
||||
'spookySparkles',
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'customizations',
|
||||
matcher: customizationMatcher([
|
||||
'hauntedHairColors',
|
||||
'supernaturalSkins',
|
||||
]),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function getGalaIndex (date) {
|
||||
const month = date instanceof moment ? date.month() : date.getMonth();
|
||||
const todayDay = date instanceof moment ? date.date() : date.getDate();
|
||||
let galaMonth = month;
|
||||
const galaCount = Object.keys(GALA_SCHEDULE).length;
|
||||
if (todayDay >= GALA_SWITCHOVER_DAY) {
|
||||
galaMonth += 1;
|
||||
}
|
||||
return parseInt((galaCount / 12) * galaMonth, 10);
|
||||
}
|
||||
|
||||
export function assembleScheduledMatchers (date) {
|
||||
const items = [];
|
||||
const month = date instanceof moment ? date.month() : date.getMonth();
|
||||
@@ -674,12 +737,8 @@ export function assembleScheduledMatchers (date) {
|
||||
items.push(...value);
|
||||
}
|
||||
}
|
||||
let galaMonth = month;
|
||||
const galaCount = Object.keys(GALA_SCHEDULE).length;
|
||||
if (todayDay >= GALA_SWITCHOVER_DAY) {
|
||||
galaMonth += 1;
|
||||
}
|
||||
items.push(...GALA_SCHEDULE[parseInt((galaCount / 12) * galaMonth, 10)]);
|
||||
|
||||
items.push(...GALA_SCHEDULE[getGalaIndex(date)]);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -688,7 +747,7 @@ let cachedScheduleMatchers = null;
|
||||
export function getScheduleMatchingGroup (type, date) {
|
||||
if (!cachedScheduleMatchers) {
|
||||
cachedScheduleMatchers = {};
|
||||
assembleScheduledMatchers(date !== undefined ? date : new Date()).forEach(matcher => {
|
||||
assembleScheduledMatchers(date || new Date()).forEach(matcher => {
|
||||
if (!cachedScheduleMatchers[matcher.type]) {
|
||||
cachedScheduleMatchers[matcher.type] = {
|
||||
matchers: [],
|
||||
@@ -718,3 +777,7 @@ export function getScheduleMatchingGroup (type, date) {
|
||||
}
|
||||
return cachedScheduleMatchers[type];
|
||||
}
|
||||
|
||||
export function getCurrentGalaKey (date) {
|
||||
return GALA_KEYS[getGalaIndex(date || new Date())];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user