2020-12-11 21:59:41 +00:00
|
|
|
import upperFirst from 'lodash/upperFirst';
|
|
|
|
|
import {
|
2024-02-01 14:06:32 +00:00
|
|
|
getCurrentGalaKey,
|
2020-12-11 21:59:41 +00:00
|
|
|
} from '../content/constants';
|
2024-02-01 14:06:32 +00:00
|
|
|
import {
|
|
|
|
|
armor,
|
|
|
|
|
} from '../content/gear/sets/special';
|
2017-09-21 00:28:11 +00:00
|
|
|
|
2024-06-06 10:21:34 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 09:56:40 +00:00
|
|
|
function getCurrentSeasonalSets (currentEvent) {
|
2024-02-01 14:06:32 +00:00
|
|
|
const year = new Date().getFullYear();
|
|
|
|
|
return {
|
2024-06-06 10:21:34 +00:00
|
|
|
rogue: safeGetSet(currentEvent, year, 'Rogue'),
|
|
|
|
|
warrior: safeGetSet(currentEvent, year, 'Warrior'),
|
|
|
|
|
wizard: safeGetSet(currentEvent, year, 'Mage'),
|
|
|
|
|
healer: safeGetSet(currentEvent, year, 'Healer'),
|
2024-02-01 14:06:32 +00:00
|
|
|
};
|
|
|
|
|
}
|
2020-12-10 22:53:37 +00:00
|
|
|
|
2024-05-15 09:56:40 +00:00
|
|
|
export default () => {
|
|
|
|
|
const currentEvent = getCurrentGalaKey();
|
2024-05-15 10:17:18 +00:00
|
|
|
const pinnedSets = getCurrentSeasonalSets(currentEvent);
|
2024-05-15 09:56:40 +00:00
|
|
|
return {
|
|
|
|
|
currentSeason: currentEvent ? upperFirst(currentEvent) : 'Closed',
|
2024-05-15 10:05:30 +00:00
|
|
|
pinnedSets,
|
|
|
|
|
featuredSet: user => {
|
|
|
|
|
if (user.stats.class) {
|
|
|
|
|
return pinnedSets[user.stats.class];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
2024-05-15 09:56:40 +00:00
|
|
|
};
|
2017-09-21 00:28:11 +00:00
|
|
|
};
|