mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
* feat(content): Winter 2025 build by @CuriousMagpie * fix(content): add more WW * fix(content): add more WW * chore(subproj): update habitica-images * fix(gala): December 2024 is Winter 2025 * fix(content): lint, background typo, 0 index month * fix(content): add missing mystery set name * fix(content): roll back erroneous month indexing * fix(tests): no 13th month, consider releases in schedule test * update gear strings * fix(seasonal): show quest modal * fix(seasonal): use category-item component * chore(subproj): update habitica-images --------- Co-authored-by: CuriousMagpie <eilatan@gmail.com>
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import upperFirst from 'lodash/upperFirst';
|
|
import {
|
|
getCurrentGalaKey,
|
|
} from '../content/constants';
|
|
import {
|
|
armor,
|
|
} from '../content/gear/sets/special';
|
|
|
|
function safeGetSet (currentEvent, year, className) {
|
|
const set = armor[`${currentEvent}${year}${className}`];
|
|
if (set) {
|
|
return set.set;
|
|
}
|
|
let checkedYear = year - 1;
|
|
while (checkedYear >= 2014) {
|
|
const oldSet = armor[`${currentEvent}${checkedYear}${className}`];
|
|
if (oldSet) {
|
|
return oldSet.set;
|
|
}
|
|
checkedYear -= 1;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function getCurrentSeasonalSets (currentEvent) {
|
|
const now = new Date();
|
|
const year = now.getMonth() === 11 ? now.getFullYear() + 1 : now.getFullYear();
|
|
return {
|
|
rogue: safeGetSet(currentEvent, year, 'Rogue'),
|
|
warrior: safeGetSet(currentEvent, year, 'Warrior'),
|
|
wizard: safeGetSet(currentEvent, year, 'Mage'),
|
|
healer: safeGetSet(currentEvent, year, 'Healer'),
|
|
};
|
|
}
|
|
|
|
export default () => {
|
|
const currentEvent = getCurrentGalaKey();
|
|
const pinnedSets = getCurrentSeasonalSets(currentEvent);
|
|
return {
|
|
currentSeason: currentEvent ? upperFirst(currentEvent) : 'Closed',
|
|
pinnedSets,
|
|
featuredSet: user => {
|
|
if (user.stats.class) {
|
|
return pinnedSets[user.stats.class];
|
|
}
|
|
return null;
|
|
},
|
|
};
|
|
};
|