feat(content): bundle and cheevo

This commit is contained in:
Sabe Jones
2021-02-16 17:00:39 -06:00
parent 0fad23ad80
commit ee1f95bb67
16 changed files with 321 additions and 136 deletions
@@ -232,6 +232,11 @@ const basicAchievs = {
titleKey: 'achievementRedLetterDay',
textKey: 'achievementRedLetterDayText',
},
legendaryBestiary: {
icon: 'achievement-legendaryBestiary',
titleKey: 'achievementLegendaryBestiary',
textKey: 'achievementLegendaryBestiaryText',
},
};
Object.assign(achievementsData, basicAchievs);
+1 -1
View File
@@ -190,7 +190,7 @@ const bundles = {
'gryphon',
],
canBuy () {
return moment().isBetween('2019-02-19', '2019-03-02');
return moment().isBefore('2021-02-28T08:00-05:00');
},
type: 'quests',
value: 7,
@@ -0,0 +1,16 @@
const ANIMAL_SET_ACHIEVEMENTS = {
legendaryBestiary: {
type: 'pet',
species: [
'Dragon',
'FlyingPig',
'Gryphon',
'SeaSerpent',
'Unicorn',
],
achievementKey: 'legendaryBestiary',
notificationType: 'ACHIEVEMENT_LEGENDARY_BESTIARY',
},
};
export default ANIMAL_SET_ACHIEVEMENTS;
@@ -30,5 +30,6 @@ export const USER_CAN_OWN_QUEST_CATEGORIES = [
export { EVENTS } from './events';
export { default as SEASONAL_SETS } from './seasonalSets';
export { default as ANIMAL_COLOR_ACHIEVEMENTS } from './animalColorAchievements';
export { default as ANIMAL_SET_ACHIEVEMENTS } from './animalSetAchievements';
export { default as QUEST_SERIES_ACHIEVEMENTS } from './questSeriesAchievements';
export { default as ITEM_LIST } from './itemList';
+2
View File
@@ -11,6 +11,7 @@ import {
ITEM_LIST,
QUEST_SERIES_ACHIEVEMENTS,
ANIMAL_COLOR_ACHIEVEMENTS,
ANIMAL_SET_ACHIEVEMENTS,
} from './constants';
import achievements from './achievements';
@@ -43,6 +44,7 @@ const api = {};
api.achievements = achievements;
api.questSeriesAchievements = QUEST_SERIES_ACHIEVEMENTS;
api.animalColorAchievements = ANIMAL_COLOR_ACHIEVEMENTS;
api.animalSetAchievements = ANIMAL_SET_ACHIEVEMENTS;
api.quests = quests;
api.questsByLevel = questsByLevel;
@@ -208,6 +208,7 @@ function _getBasicAchievements (user, language) {
_addSimple(result, user, { path: 'skeletonCrew', language });
_addSimple(result, user, { path: 'seeingRed', language });
_addSimple(result, user, { path: 'redLetterDay', language });
_addSimple(result, user, { path: 'legendaryBestiary', language });
_addSimpleWithMasterCount(result, user, { path: 'beastMaster', language });
_addSimpleWithMasterCount(result, user, { path: 'mountMaster', language });
+49 -17
View File
@@ -59,25 +59,57 @@ export default function hatch (user, req = {}, analytics) {
checkOnboardingStatus(user, req, analytics);
}
forEach(content.animalColorAchievements, achievement => {
if (!user.achievements[achievement.petAchievement]) {
const petIndex = findIndex(
keys(content.dropEggs),
animal => !user.items.pets[`${animal}-${achievement.color}`] || user.items.pets[`${animal}-${achievement.color}`] <= 0,
);
if (petIndex === -1) {
user.achievements[achievement.petAchievement] = true;
if (user.addNotification) {
const achievementString = `achievement${upperFirst(achievement.petAchievement)}`;
user.addNotification(achievement.petNotificationType, {
achievement: achievement.petAchievement,
message: `${i18n.t('modalAchievement')} ${i18n.t(achievementString)}`,
modalText: i18n.t(`${achievementString}ModalText`),
});
if (content.dropEggs[egg]) {
forEach(content.animalColorAchievements, achievement => {
if (hatchingPotion !== achievement.color) return;
if (!user.achievements[achievement.petAchievement]) {
const petIndex = findIndex(
keys(content.dropEggs),
animal => !user.items.pets[`${animal}-${achievement.color}`] || user.items.pets[`${animal}-${achievement.color}`] <= 0,
);
if (petIndex === -1) {
user.achievements[achievement.petAchievement] = true;
if (user.addNotification) {
const achievementString = `achievement${upperFirst(achievement.petAchievement)}`;
user.addNotification(achievement.petNotificationType, {
achievement: achievement.petAchievement,
message: `${i18n.t('modalAchievement')} ${i18n.t(achievementString)}`,
modalText: i18n.t(`${achievementString}ModalText`),
});
}
}
}
}
});
});
}
if (content.dropHatchingPotions[hatchingPotion]) {
forEach(content.animalSetAchievements, achievement => {
if (!user.achievements[achievement.achievementKey]) {
if (achievement.type === 'pet') {
let achieved = true;
forEach(achievement.species, species => {
if (!achieved) return;
const petIndex = findIndex(
keys(content.dropHatchingPotions),
color => !user.items.pets[`${species}-${color}`],
);
if (petIndex !== -1) achieved = false;
});
if (achieved) {
user.achievements[achievement.achievementKey] = true;
if (user.addNotification) {
const achievementString = `achievement${upperFirst(achievement.achievementKey)}`;
user.addNotification(achievement.notificationType, {
achievement: achievement.achievementKey,
message: `${i18n.t('modalAchievement')} ${i18n.t(achievementString)}`,
modalText: i18n.t(`${achievementString}ModalText`),
});
}
}
}
}
});
}
if (analytics && moment().diff(user.auth.timestamps.created, 'days') < 7) {
analytics.track('pet hatch', {