Skip to content

Commit

Permalink
add May achievement
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousMagpie committed Apr 3, 2024
1 parent a34a75d commit b7dc78f
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
99 changes: 99 additions & 0 deletions migrations/archive/2024/20240516_pet_group_achievements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '202405_pet_group_achievements';
import { model as User } from '../../../website/server/models/user';

const progressCount = 1000;
let count = 0;

async function updateUser (user) {
count++;

let set = {
migration: MIGRATION_NAME,
};

if (user && user.items && user.items.pets) {
const pets = user.items.pets;
if (pets['Lion-Zombie'] > 0
&& pets['Lion-Skeleton'] > 0
&& pets['Lion-Base'] > 0
&& pets['Lion-Desert'] > 0
&& pets['Lion-Red'] > 0
&& pets['Lion-Shade'] > 0
&& pets['Lion-White']> 0
&& pets['Lion-Golden'] > 0
&& pets['Lion-CottonCandyBlue'] > 0
&& pets['Lion-CottonCandyPink'] > 0
&& pets['Tiger-Zombie'] > 0
&& pets['Tiger-Skeleton'] > 0
&& pets['Tiger-Base'] > 0
&& pets['Tiger-Desert'] > 0
&& pets['Tiger-Red'] > 0
&& pets['Tiger-Shade'] > 0
&& pets['Tiger-White'] > 0
&& pets['Tiger-Golden'] > 0
&& pets['Tiger-CottonCandyBlue'] > 0
&& pets['Tiger-CottonCandyPink'] > 0
&& pets['Sabretooth-Zombie'] > 0
&& pets['Sabretooth-Skeleton'] > 0
&& pets['Sabretooth-Base'] > 0
&& pets['Sabretooth-Desert'] > 0
&& pets['Sabretooth-Red'] > 0
&& pets['Sabretooth-Shade'] > 0
&& pets['Sabretooth-White'] > 0
&& pets['Sabretooth-Golden'] > 0
&& pets['Sabretooth-CottonCandyBlue'] > 0
&& pets['Sabretooth-CottonCandyPink'] > 0
&& pets['Cheetah-Zombie'] > 0
&& pets['Cheetah-Skeleton'] > 0
&& pets['Cheetah-Base'] > 0
&& pets['Cheetah-Desert'] > 0
&& pets['Cheetah-Red'] > 0
&& pets['Cheetah-Shade'] > 0
&& pets['Cheetah-White'] > 0
&& pets['Cheetah-Golden'] > 0
&& pets['Cheetah-CottonCandyBlue'] > 0
&& pets['Cheetah-CottonCandyPink'] > 0 ) {
set['achievements.cats'] = true;

}
}

if (count % progressCount === 0) console.warn(`${count} ${user._id}`);

return await User.updateOne({ _id: user._id }, { $set: set }).exec();
}

export default async function processUsers () {
let query = {
migration: { $ne: MIGRATION_NAME },
'auth.timestamps.loggedin': { $gt: new Date('2024-03-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
}
};
5 changes: 4 additions & 1 deletion website/common/locales/en/achievements.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
"achievementRoughRiderModalText": "You collected all the basic colors of the uncomfortable pets and mounts!",
"achievementRodentRuler": "Rodent Ruler",
"achievementRodentRulerText": "Has hatched all standard colors of rodent pets: Guinea Pig, Rat, and Squirrel!",
"achievementRodentRulerModalText": "You collected all the rodent pets!"
"achievementRodentRulerModalText": "You collected all the rodent pets!",
"achievementCats": "Cat Herder",
"achievementCatsText": "Has hatched all the standard colors of cat pets: Cheetah, Lion, Sabretooth, Tiger!",
"achievementCatsModalText": "You collected all the cat pets!"

}
6 changes: 6 additions & 0 deletions website/common/script/content/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ const animalSetAchievs = {
titleKey: 'achievementBonelessBoss',
textKey: 'achievementBonelessBossText',
},
cats: {
icon: 'achievement-cats',
titleKey: 'achievementCats',
textKey: 'achievementCatsText',
release: '2024-05-16T08:00-04:00',
},
dinosaurDynasty: {
icon: 'achievement-dinosaurDynasty',
titleKey: 'achievementDinosaurDynasty',
Expand Down
11 changes: 11 additions & 0 deletions website/common/script/content/constants/animalSetAchievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ const ANIMAL_SET_ACHIEVEMENTS = {
achievementKey: 'bonelessBoss',
notificationType: 'ACHIEVEMENT_ANIMAL_SET',
},
cats: {
type: 'pet',
species: [
'Cheetah',
'Lion',
'Sabretooth',
'Tiger',
],
achievementKey: 'cats',
noitificationType: 'ACHIEVEMENT_ANIMAL_SET',
},
dinosaurDynasty: {
type: 'pet',
species: [
Expand Down
1 change: 1 addition & 0 deletions website/common/script/libs/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ function _getBasicAchievements (user, language) {
_addSimple(result, user, { path: 'duneBuddy', language });
_addSimple(result, user, { path: 'roughRider', language });
_addSimple(result, user, { path: 'rodentRuler', language });
_addSimple(result, user, { path: 'cats', language });

_addSimpleWithMasterCount(result, user, { path: 'beastMaster', language });
_addSimpleWithMasterCount(result, user, { path: 'mountMaster', language });
Expand Down
1 change: 1 addition & 0 deletions website/server/models/user/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const UserSchema = new Schema({
duneBuddy: Boolean,
roughRider: Boolean,
rodentRuler: Boolean,
cats: Boolean,
// Onboarding Guide
createdTask: Boolean,
completedTask: Boolean,
Expand Down

0 comments on commit b7dc78f

Please sign in to comment.