diff --git a/habitica-images b/habitica-images index 4ab9833a58..9e8d821858 160000 --- a/habitica-images +++ b/habitica-images @@ -1 +1 @@ -Subproject commit 4ab9833a58bbc85b7b0ad8dff1ee01535270dcfe +Subproject commit 9e8d8218584fe65f71d84b8cb4a22202c58cd7a5 diff --git a/migrations/archive/2022/20210129_habit_birthday.js b/migrations/archive/2022/20210129_habit_birthday.js new file mode 100644 index 0000000000..e1740fef73 --- /dev/null +++ b/migrations/archive/2022/20210129_habit_birthday.js @@ -0,0 +1,97 @@ +/* eslint-disable no-console */ +const MIGRATION_NAME = '20220131_habit_birthday'; +import { v4 as uuid } from 'uuid'; + +import { model as User } from '../../../website/server/models/user'; + +const progressCount = 1000; +let count = 0; + +async function updateUser (user) { + count++; + + const inc = { + 'items.food.Cake_Skeleton': 1, + 'items.food.Cake_Base': 1, + 'items.food.Cake_CottonCandyBlue': 1, + 'items.food.Cake_CottonCandyPink': 1, + 'items.food.Cake_Shade': 1, + 'items.food.Cake_White': 1, + 'items.food.Cake_Golden': 1, + 'items.food.Cake_Zombie': 1, + 'items.food.Cake_Desert': 1, + 'items.food.Cake_Red': 1, + 'achievements.habitBirthdays': 1, + }; + const set = {}; + let push; + + set.migration = MIGRATION_NAME; + + if (typeof user.items.gear.owned.armor_special_birthday2021 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2022'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2022', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2020 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2021'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2021', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2019 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2020'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2020', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2018 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2019'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2019', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2017 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2018'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2018', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2016 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2017'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2017', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday2015 !== 'undefined') { + set['items.gear.owned.armor_special_birthday2016'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2016', _id: uuid()}}; + } else if (typeof user.items.gear.owned.armor_special_birthday !== 'undefined') { + set['items.gear.owned.armor_special_birthday2015'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2015', _id: uuid()}}; + } else { + set['items.gear.owned.armor_special_birthday'] = false; + push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday', _id: uuid()}}; + } + + if (count % progressCount === 0) console.warn(`${count} ${user._id}`); + + return await User.update({_id: user._id}, {$inc: inc, $set: set, $push: push}).exec(); +} + +export default async function processUsers () { + let query = { + // migration: {$ne: MIGRATION_NAME}, + 'auth.timestamps.loggedin': {$gt: new Date('2022-01-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], + }; + } + + await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop + } +}; diff --git a/website/common/locales/en/gear.json b/website/common/locales/en/gear.json index dbb4ef6484..07026f8d9b 100644 --- a/website/common/locales/en/gear.json +++ b/website/common/locales/en/gear.json @@ -729,6 +729,9 @@ "armorSpecialBirthday2020Notes": "Happy Birthday, Habitica! Wear these Outrageous Party Robes to celebrate this wonderful day. Confers no benefit.", "armorSpecialBirthday2021Text": "Extravagant Party Robes", "armorSpecialBirthday2021Notes": "Happy Birthday, Habitica! Wear these Extravagant Party Robes to celebrate this wonderful day. Confers no benefit.", + "armorSpecialBirthday2022Text": "Preposterous Party Robes", + "armorSpecialBirthday2022Notes": "Happy Birthday, Habitica! Wear these Proposterous Party Robes to celebrate this wonderful day. Confers no benefit.", + "armorSpecialGaymerxText": "Rainbow Warrior Armor", "armorSpecialGaymerxNotes": "In celebration of the GaymerX Conference, this special armor is decorated with a radiant, colorful rainbow pattern! GaymerX is a game convention celebrating LGTBQ and gaming and is open to everyone.", diff --git a/website/common/script/content/gear/sets/special/index.js b/website/common/script/content/gear/sets/special/index.js index 3761465bf9..3427057675 100644 --- a/website/common/script/content/gear/sets/special/index.js +++ b/website/common/script/content/gear/sets/special/index.js @@ -716,6 +716,12 @@ const armor = { winter2022Healer: { set: 'winter2022IceCrystalHealerSet', }, + birthday2022: { + text: t('armorSpecialBirthday2022Text'), + notes: t('armorSpecialBirthday2022Notes'), + value: 0, + canOwn: ownsItem('armor_special_birthday2022'), + }, }; const armorStats = {