feat(content): Red Pet Achievement

This commit is contained in:
Sabe Jones
2020-11-24 17:53:15 -06:00
parent f44b331680
commit c4f6644c3a
10 changed files with 132 additions and 2 deletions

View File

@@ -0,0 +1,82 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20201124_pet_color_achievements';
import { model as User } from '../../../website/server/models/user';
const progressCount = 1000;
let count = 0;
async function updateUser (user) {
count++;
const set = {
migration: MIGRATION_NAME,
};
if (user && user.items && user.items.pets) {
const pets = user.items.pets;
if (pets['Wolf-Red'] > 0
&& pets['TigerCub-Red'] > 0
&& pets['PandaCub-Red'] > 0
&& pets['LionCub-Red'] > 0
&& pets['Fox-Red'] > 0
&& pets['FlyingPig-Red'] > 0
&& pets['Dragon-Red'] > 0
&& pets['Cactus-Red'] > 0
&& pets['BearCub-Red'] > 0) {
set['achievements.seeingRed'] = true;
}
}
if (user && user.items && user.items.mounts) {
const mounts = user.items.mounts;
if (mounts['Wolf-Red']
&& mounts['TigerCub-Red']
&& mounts['PandaCub-Red']
&& mounts['LionCub-Red']
&& mounts['Fox-Red']
&& mounts['FlyingPig-Red']
&& mounts['Dragon-Red']
&& mounts['Cactus-Red']
&& mounts['BearCub-Red'] ) {
set['achievements.redLetterDay'] = true;
}
}
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await User.update({ _id: user._id }, { $set: set }).exec();
}
module.exports = async function processUsers () {
let query = {
migration: { $ne: MIGRATION_NAME },
'auth.timestamps.loggedin': { $gt: new Date('2020-11-01') },
};
const fields = {
_id: 1,
items: 1,
};
while (true) { // eslint-disable-line no-constant-condition
const users = await User // eslint-disable-line no-await-in-loop
.find(query)
.limit(250)
.sort({_id: 1})
.select(fields)
.lean()
.exec();
if (users.length === 0) {
console.warn('All appropriate users found and modified.');
console.warn(`\n${count} users processed\n`);
break;
} else {
query._id = {
$gt: users[users.length - 1]._id,
};
}
await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop
}
};

View File

@@ -370,6 +370,22 @@ const NOTIFICATIONS = {
achievement: 'skeletonCrew', achievement: 'skeletonCrew',
}, },
}, },
ACHIEVEMENT_SEEING_RED: {
achievement: true,
label: $t => `${$t('achievement')}: ${$t('achievementSeeingRed')}`,
modalId: 'generic-achievement',
data: {
achievement: 'seeingRed',
},
},
ACHIEVEMENT_RED_LETTER_DAY: {
achievement: true,
label: $t => `${$t('achievement')}: ${$t('achievementRedLetterDay')}`,
modalId: 'generic-achievement',
data: {
achievement: 'redLetterDay',
},
},
}; };
export default { export default {
@@ -431,7 +447,8 @@ export default {
'ACHIEVEMENT_PEARLY_PRO', 'ACHIEVEMENT_TICKLED_PINK', 'ACHIEVEMENT_ROSY_OUTLOOK', 'ACHIEVEMENT', 'ACHIEVEMENT_PEARLY_PRO', 'ACHIEVEMENT_TICKLED_PINK', 'ACHIEVEMENT_ROSY_OUTLOOK', 'ACHIEVEMENT',
'ONBOARDING_COMPLETE', 'FIRST_DROPS', 'ACHIEVEMENT_BUG_BONANZA', 'ACHIEVEMENT_BARE_NECESSITIES', 'ONBOARDING_COMPLETE', 'FIRST_DROPS', 'ACHIEVEMENT_BUG_BONANZA', 'ACHIEVEMENT_BARE_NECESSITIES',
'ACHIEVEMENT_FRESHWATER_FRIENDS', 'ACHIEVEMENT_GOOD_AS_GOLD', 'ACHIEVEMENT_ALL_THAT_GLITTERS', 'ACHIEVEMENT_FRESHWATER_FRIENDS', 'ACHIEVEMENT_GOOD_AS_GOLD', 'ACHIEVEMENT_ALL_THAT_GLITTERS',
'ACHIEVEMENT_BONE_COLLECTOR', 'ACHIEVEMENT_SKELETON_CREW', 'ACHIEVEMENT_BONE_COLLECTOR', 'ACHIEVEMENT_SKELETON_CREW', 'ACHIEVEMENT_SEEING_RED',
'ACHIEVEMENT_RED_LETTER_DAY',
].forEach(type => { ].forEach(type => {
handledNotifications[type] = true; handledNotifications[type] = true;
}); });
@@ -850,6 +867,8 @@ export default {
case 'ACHIEVEMENT_ALL_THAT_GLITTERS': case 'ACHIEVEMENT_ALL_THAT_GLITTERS':
case 'ACHIEVEMENT_BONE_COLLECTOR': case 'ACHIEVEMENT_BONE_COLLECTOR':
case 'ACHIEVEMENT_SKELETON_CREW': case 'ACHIEVEMENT_SKELETON_CREW':
case 'ACHIEVEMENT_SEEING_RED':
case 'ACHIEVEMENT_RED_LETTER_DAY':
case 'GENERIC_ACHIEVEMENT': case 'GENERIC_ACHIEVEMENT':
this.showNotificationWithModal(notification); this.showNotificationWithModal(notification);
break; break;

View File

@@ -96,5 +96,11 @@
"achievementBoneCollectorModalText": "You collected all the Skeleton Pets!", "achievementBoneCollectorModalText": "You collected all the Skeleton Pets!",
"achievementSkeletonCrew": "Skeleton Crew", "achievementSkeletonCrew": "Skeleton Crew",
"achievementSkeletonCrewText": "Has tamed all Skeleton Mounts.", "achievementSkeletonCrewText": "Has tamed all Skeleton Mounts.",
"achievementSkeletonCrewModalText": "You tamed all the Skeleton Mounts!" "achievementSkeletonCrewModalText": "You tamed all the Skeleton Mounts!",
"achievementSeeingRed": "Seeing Red",
"achievementSeeingRedText": "Has collected all Red pets.",
"achievementSeeingRedModalText": "You collected all the Red Pets!",
"achievementRedLetterDay": "Red Letter Day",
"achievementRedLetterDayText": "Has tamed all Red Mounts.",
"achievementRedLetterDayModalText": "You tamed all the Red Mounts!"
} }

View File

@@ -222,6 +222,16 @@ const basicAchievs = {
titleKey: 'achievementSkeletonCrew', titleKey: 'achievementSkeletonCrew',
textKey: 'achievementSkeletonCrewText', textKey: 'achievementSkeletonCrewText',
}, },
seeingRed: {
icon: 'achievement-seeingRed',
titleKey: 'achievementSeeingRed',
textKey: 'achievementSeeingRedText',
},
redLetterDay: {
icon: 'achievement-redLetterDay',
titleKey: 'achievementRedLetterDay',
textKey: 'achievementRedLetterDayText',
},
}; };
Object.assign(achievementsData, basicAchievs); Object.assign(achievementsData, basicAchievs);

View File

@@ -48,6 +48,13 @@ const ANIMAL_COLOR_ACHIEVEMENTS = [
mountAchievement: 'skeletonCrew', mountAchievement: 'skeletonCrew',
mountNotificationType: 'ACHIEVEMENT_SKELETON_CREW', mountNotificationType: 'ACHIEVEMENT_SKELETON_CREW',
}, },
{
color: 'Red',
petAchievement: 'seeingRed',
petNotificationType: 'ACHIEVEMENT_SEEING_RED',
mountAchievement: 'redLetterDay',
mountNotificationType: 'ACHIEVEMENT_RED_LETTER_DAY',
},
]; ];
export default ANIMAL_COLOR_ACHIEVEMENTS; export default ANIMAL_COLOR_ACHIEVEMENTS;

View File

@@ -206,6 +206,8 @@ function _getBasicAchievements (user, language) {
_addSimple(result, user, { path: 'allThatGlitters', language }); _addSimple(result, user, { path: 'allThatGlitters', language });
_addSimple(result, user, { path: 'boneCollector', language }); _addSimple(result, user, { path: 'boneCollector', language });
_addSimple(result, user, { path: 'skeletonCrew', language }); _addSimple(result, user, { path: 'skeletonCrew', language });
_addSimple(result, user, { path: 'seeingRed', language });
_addSimple(result, user, { path: 'redLetterDay', language });
_addSimpleWithMasterCount(result, user, { path: 'beastMaster', language }); _addSimpleWithMasterCount(result, user, { path: 'beastMaster', language });
_addSimpleWithMasterCount(result, user, { path: 'mountMaster', language }); _addSimpleWithMasterCount(result, user, { path: 'mountMaster', language });

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -138,6 +138,8 @@ export default new Schema({
allThatGlitters: Boolean, allThatGlitters: Boolean,
boneCollector: Boolean, boneCollector: Boolean,
skeletonCrew: Boolean, skeletonCrew: Boolean,
seeingRed: Boolean,
redLetterDay: Boolean,
// Onboarding Guide // Onboarding Guide
createdTask: Boolean, createdTask: Boolean,
completedTask: Boolean, completedTask: Boolean,

View File

@@ -61,6 +61,8 @@ const NOTIFICATION_TYPES = [
'ACHIEVEMENT_ALL_THAT_GLITTERS', 'ACHIEVEMENT_ALL_THAT_GLITTERS',
'ACHIEVEMENT_BONE_COLLECTOR', 'ACHIEVEMENT_BONE_COLLECTOR',
'ACHIEVEMENT_SKELETON_CREW', 'ACHIEVEMENT_SKELETON_CREW',
'ACHIEVEMENT_SEEING_RED',
'ACHIEVEMENT_RED_LETTER_DAY',
'ACHIEVEMENT', // generic achievement notification, details inside `notification.data` 'ACHIEVEMENT', // generic achievement notification, details inside `notification.data`
'DROP_CAP_REACHED', 'DROP_CAP_REACHED',
]; ];