mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
feat(content): new pet color achievements
This commit is contained in:
82
migrations/archive/2021/20210525_pet_color_achievements.js
Normal file
82
migrations/archive/2021/20210525_pet_color_achievements.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/* eslint-disable no-console */
|
||||
const MIGRATION_NAME = '20210525_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-CottonCandyBlue'] > 0
|
||||
&& pets['TigerCub-CottonCandyBlue'] > 0
|
||||
&& pets['PandaCub-CottonCandyBlue'] > 0
|
||||
&& pets['LionCub-CottonCandyBlue'] > 0
|
||||
&& pets['Fox-CottonCandyBlue'] > 0
|
||||
&& pets['FlyingPig-CottonCandyBlue'] > 0
|
||||
&& pets['Dragon-CottonCandyBlue'] > 0
|
||||
&& pets['Cactus-CottonCandyBlue'] > 0
|
||||
&& pets['BearCub-CottonCandyBlue'] > 0) {
|
||||
set['achievements.violetsAreBlue'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (user && user.items && user.items.mounts) {
|
||||
const mounts = user.items.mounts;
|
||||
if (mounts['Wolf-CottonCandyBlue']
|
||||
&& mounts['TigerCub-CottonCandyBlue']
|
||||
&& mounts['PandaCub-CottonCandyBlue']
|
||||
&& mounts['LionCub-CottonCandyBlue']
|
||||
&& mounts['Fox-CottonCandyBlue']
|
||||
&& mounts['FlyingPig-CottonCandyBlue']
|
||||
&& mounts['Dragon-CottonCandyBlue']
|
||||
&& mounts['Cactus-CottonCandyBlue']
|
||||
&& mounts['BearCub-CottonCandyBlue'] ) {
|
||||
set['achievements.wildBlueYonder'] = 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('2021-05-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
|
||||
}
|
||||
};
|
||||
@@ -403,6 +403,22 @@ const NOTIFICATIONS = {
|
||||
achievement: 'seasonalSpecialist',
|
||||
},
|
||||
},
|
||||
ACHIEVEMENT_VIOLETS_ARE_BLUE: {
|
||||
achievement: true,
|
||||
label: $t => `${$t('achievement')}: ${$t('achievementVioletsAreBlue')}`,
|
||||
modalId: 'generic-achievement',
|
||||
data: {
|
||||
achievement: 'violetsAreBlue',
|
||||
},
|
||||
},
|
||||
ACHIEVEMENT_WILD_BLUE_YONDER: {
|
||||
achievement: true,
|
||||
label: $t => `${$t('achievement')}: ${$t('achievementWildBlueYonder')}`,
|
||||
modalId: 'generic-achievement',
|
||||
data: {
|
||||
achievement: 'wildBlueYonder',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -466,6 +482,7 @@ export default {
|
||||
'ACHIEVEMENT_FRESHWATER_FRIENDS', 'ACHIEVEMENT_GOOD_AS_GOLD', 'ACHIEVEMENT_ALL_THAT_GLITTERS',
|
||||
'ACHIEVEMENT_BONE_COLLECTOR', 'ACHIEVEMENT_SKELETON_CREW', 'ACHIEVEMENT_SEEING_RED',
|
||||
'ACHIEVEMENT_RED_LETTER_DAY', 'ACHIEVEMENT_LEGENDARY_BESTIARY', 'ACHIEVEMENT_SEASONAL_SPECIALIST',
|
||||
'ACHIEVEMENT_VIOLETS_ARE_BLUE', 'ACHIEVEMENT_WILD_BLUE_YONDER',
|
||||
].forEach(type => {
|
||||
handledNotifications[type] = true;
|
||||
});
|
||||
@@ -890,6 +907,8 @@ export default {
|
||||
case 'ACHIEVEMENT_RED_LETTER_DAY':
|
||||
case 'ACHIEVEMENT_LEGENDARY_BESTIARY':
|
||||
case 'ACHIEVEMENT_SEASONAL_SPECIALIST':
|
||||
case 'ACHIEVEMENT_VIOLETS_ARE_BLUE':
|
||||
case 'ACHIEVEMENT_WILD_BLUE_YONDER':
|
||||
case 'GENERIC_ACHIEVEMENT':
|
||||
this.showNotificationWithModal(notification);
|
||||
break;
|
||||
|
||||
@@ -108,5 +108,11 @@
|
||||
"achievementLegendaryBestiaryModalText": "You collected all the mythical pets!",
|
||||
"achievementSeasonalSpecialist": "Seasonal Specialist",
|
||||
"achievementSeasonalSpecialistText": "Has completed all the Spring and Winter seasonal quests: Egg Hunt, Trapper Santa, and Find the Cub!",
|
||||
"achievementSeasonalSpecialistModalText": "You completed all the seasonal quests!"
|
||||
"achievementSeasonalSpecialistModalText": "You completed all the seasonal quests!",
|
||||
"achievementVioletsAreBlue": "Violets are Blue",
|
||||
"achievementVioletsAreBlueText": "Has collected all Cotton Candy Blue Pets.",
|
||||
"achievementVioletsAreBlueModalText": "You collected all the Cotton Candy Blue Pets!",
|
||||
"achievementWildBlueYonder": "Wild Blue Yonder",
|
||||
"achievementWildBlueYonderText": "Has tamed all Cotton Candy Blue Mounts.",
|
||||
"achievementWildBlueYonderModalText": "You tamed all the Cotton Candy Blue Mounts!"
|
||||
}
|
||||
|
||||
@@ -242,6 +242,16 @@ const basicAchievs = {
|
||||
titleKey: 'achievementSeasonalSpecialist',
|
||||
textKey: 'achievementSeasonalSpecialistText',
|
||||
},
|
||||
violetsAreBlue: {
|
||||
icon: 'achievement-violetsAreBlue',
|
||||
titleKey: 'achievementVioletsAreBlue',
|
||||
textKey: 'achievementVioletsAreBlueText',
|
||||
},
|
||||
wildBlueYonder: {
|
||||
icon: 'achievement-wildBlueYonder',
|
||||
titleKey: 'achievementWildBlueYonder',
|
||||
textKey: 'achievementWildBlueYonderText',
|
||||
},
|
||||
};
|
||||
Object.assign(achievementsData, basicAchievs);
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ const ANIMAL_COLOR_ACHIEVEMENTS = [
|
||||
mountAchievement: 'redLetterDay',
|
||||
mountNotificationType: 'ACHIEVEMENT_RED_LETTER_DAY',
|
||||
},
|
||||
{
|
||||
color: 'CottonCandyBlue',
|
||||
petAchievement: 'violetsAreBlue',
|
||||
petNotificationType: 'ACHIEVEMENT_VIOLETS_ARE_BLUE',
|
||||
mountAchievement: 'wildBlueYonder',
|
||||
mountNotificationType: 'ACHIEVEMENT_WILD_BLUE_YONDER',
|
||||
},
|
||||
];
|
||||
|
||||
export default ANIMAL_COLOR_ACHIEVEMENTS;
|
||||
|
||||
@@ -210,6 +210,8 @@ function _getBasicAchievements (user, language) {
|
||||
_addSimple(result, user, { path: 'redLetterDay', language });
|
||||
_addSimple(result, user, { path: 'legendaryBestiary', language });
|
||||
_addSimple(result, user, { path: 'seasonalSpecialist', language });
|
||||
_addSimple(result, user, { path: 'violetsAreBlue', language });
|
||||
_addSimple(result, user, { path: 'wildBlueYonder', language });
|
||||
|
||||
_addSimpleWithMasterCount(result, user, { path: 'beastMaster', language });
|
||||
_addSimpleWithMasterCount(result, user, { path: 'mountMaster', language });
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
@@ -142,6 +142,8 @@ export default new Schema({
|
||||
redLetterDay: Boolean,
|
||||
legendaryBestiary: Boolean,
|
||||
seasonalSpecialist: Boolean,
|
||||
violetsAreBlue: Boolean,
|
||||
wildBlueYonder: Boolean,
|
||||
// Onboarding Guide
|
||||
createdTask: Boolean,
|
||||
completedTask: Boolean,
|
||||
|
||||
@@ -65,6 +65,8 @@ const NOTIFICATION_TYPES = [
|
||||
'ACHIEVEMENT_RED_LETTER_DAY',
|
||||
'ACHIEVEMENT_LEGENDARY_BESTIARY',
|
||||
'ACHIEVEMENT_SEASONAL_SPECIALIST',
|
||||
'ACHIEVEMENT_VIOLETS_ARE_BLUE',
|
||||
'ACHIEVEMENT_WILD_BLUE_YONDER',
|
||||
'ACHIEVEMENT', // generic achievement notification, details inside `notification.data`
|
||||
'DROP_CAP_REACHED',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user