mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
chore(content): add NYE party hat and migration script (#14419)
* chore(content): add NYE party hat and migration script * chore(subproj): update habitica-images * chore(sprites): corrected sprite CSS run * fix(event): unbork migration, add latecomer hook Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Submodule habitica-images updated: e8f76ad308...c1e8973a66
144
migrations/archive/2022/20221227_nye.js
Normal file
144
migrations/archive/2022/20221227_nye.js
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
const MIGRATION_NAME = '20221227_nye';
|
||||||
|
import { model as User } from '../../../website/server/models/user';
|
||||||
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
|
const progressCount = 1000;
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
async function updateUser (user) {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
const set = { migration: MIGRATION_NAME };
|
||||||
|
let push;
|
||||||
|
|
||||||
|
if (typeof user.items.gear.owned.head_special_nye2021 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2022'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2022',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2020 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2021'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2021',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2019 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2020'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2020',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2018 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2019'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2019',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2017 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2018'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2018',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2016 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2017'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2017',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2015 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2016'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2016',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye2014 !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2015'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2015',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (typeof user.items.gear.owned.head_special_nye !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_nye2014'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye2014',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
set['items.gear.owned.head_special_nye'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_nye',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||||
|
|
||||||
|
return await User.update({_id: user._id}, {$set: set, $push: {pinnedItems: {$each: push}}}).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function processUsers () {
|
||||||
|
let query = {
|
||||||
|
'auth.timestamps.loggedin': {$gt: new Date('2022-12-01')},
|
||||||
|
migration: {$ne: MIGRATION_NAME},
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -31355,6 +31355,11 @@
|
|||||||
width: 114px;
|
width: 114px;
|
||||||
height: 90px;
|
height: 90px;
|
||||||
}
|
}
|
||||||
|
.head_special_nye2022 {
|
||||||
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_special_nye2022.png');
|
||||||
|
width: 114px;
|
||||||
|
height: 90px;
|
||||||
|
}
|
||||||
.head_special_ski {
|
.head_special_ski {
|
||||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_special_ski.png');
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_special_ski.png');
|
||||||
width: 90px;
|
width: 90px;
|
||||||
@@ -31950,6 +31955,11 @@
|
|||||||
width: 68px;
|
width: 68px;
|
||||||
height: 68px;
|
height: 68px;
|
||||||
}
|
}
|
||||||
|
.shop_head_special_nye2022 {
|
||||||
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_special_nye2022.png');
|
||||||
|
width: 68px;
|
||||||
|
height: 68px;
|
||||||
|
}
|
||||||
.shop_head_special_ski {
|
.shop_head_special_ski {
|
||||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_special_ski.png');
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_special_ski.png');
|
||||||
width: 68px;
|
width: 68px;
|
||||||
@@ -32295,6 +32305,11 @@
|
|||||||
width: 68px;
|
width: 68px;
|
||||||
height: 68px;
|
height: 68px;
|
||||||
}
|
}
|
||||||
|
.shop_weapon_special_Winter2023Rogue {
|
||||||
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_Winter2023Rogue.png');
|
||||||
|
width: 68px;
|
||||||
|
height: 68px;
|
||||||
|
}
|
||||||
.shop_weapon_special_candycane {
|
.shop_weapon_special_candycane {
|
||||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_candycane.png');
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_candycane.png');
|
||||||
width: 68px;
|
width: 68px;
|
||||||
@@ -32480,11 +32495,6 @@
|
|||||||
width: 68px;
|
width: 68px;
|
||||||
height: 68px;
|
height: 68px;
|
||||||
}
|
}
|
||||||
.shop_weapon_special_winter2023Rogue {
|
|
||||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_winter2023Rogue.png');
|
|
||||||
width: 68px;
|
|
||||||
height: 68px;
|
|
||||||
}
|
|
||||||
.shop_weapon_special_winter2023Warrior {
|
.shop_weapon_special_winter2023Warrior {
|
||||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_winter2023Warrior.png');
|
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_weapon_special_winter2023Warrior.png');
|
||||||
width: 68px;
|
width: 68px;
|
||||||
|
|||||||
@@ -438,6 +438,9 @@
|
|||||||
"headSpecialNye2021Text": "Preposterous Party Hat",
|
"headSpecialNye2021Text": "Preposterous Party Hat",
|
||||||
"headSpecialNye2021Notes": "You've received a Preposterous Party Hat! Wear it with pride while ringing in the New Year! Confers no benefit.",
|
"headSpecialNye2021Notes": "You've received a Preposterous Party Hat! Wear it with pride while ringing in the New Year! Confers no benefit.",
|
||||||
|
|
||||||
|
"headSpecialNye2022Text": "Fantastic Party Hat",
|
||||||
|
"headSpecialNye2022Notes": "You've received a Fantastic Party Hat! Wear it with pride while ringing in the New Year! Confers no benefit.",
|
||||||
|
|
||||||
"weaponSpecialSpring2022RogueText": "Giant Earring Stud",
|
"weaponSpecialSpring2022RogueText": "Giant Earring Stud",
|
||||||
"weaponSpecialSpring2022RogueNotes": "A shiny! It’s so shiny and gleaming and pretty and nice and all yours! Increases Strength by <%= str %>. Limited Edition 2022 Spring Gear.",
|
"weaponSpecialSpring2022RogueNotes": "A shiny! It’s so shiny and gleaming and pretty and nice and all yours! Increases Strength by <%= str %>. Limited Edition 2022 Spring Gear.",
|
||||||
"weaponSpecialSpring2022WarriorText": "Inside-Out Umbrella",
|
"weaponSpecialSpring2022WarriorText": "Inside-Out Umbrella",
|
||||||
|
|||||||
@@ -1932,6 +1932,12 @@ const head = {
|
|||||||
winter2023Healer: {
|
winter2023Healer: {
|
||||||
set: 'winter2023CardinalHealerSet',
|
set: 'winter2023CardinalHealerSet',
|
||||||
},
|
},
|
||||||
|
nye2022: {
|
||||||
|
text: t('headSpecialNye2022Text'),
|
||||||
|
notes: t('headSpecialNye2022Notes'),
|
||||||
|
value: 0,
|
||||||
|
canOwn: ownsItem('head_special_nye2022'),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const headStats = {
|
const headStats = {
|
||||||
|
|||||||
@@ -150,10 +150,10 @@ function _setUpNewUser (user) {
|
|||||||
user.items.quests.dustbunnies = 1;
|
user.items.quests.dustbunnies = 1;
|
||||||
user.purchased.background.violet = true;
|
user.purchased.background.violet = true;
|
||||||
user.preferences.background = 'violet';
|
user.preferences.background = 'violet';
|
||||||
if (moment().isBetween('2022-11-22T08:00-05:00', '2022-11-27T20:00-05:00')) {
|
if (moment().isBetween('2022-12-27T08:00-05:00', '2023-01-02T20:00-05:00')) {
|
||||||
user.migration = '20221122_harvest_feast';
|
user.migration = '20221227_nye';
|
||||||
user.items.pets['Turkey-Base'] = 5;
|
user.items.gear.owned.head_special_nye = true;
|
||||||
user.items.currentPet = 'Turkey-Base';
|
user.items.gear.equipped.head = 'head_special_nye';
|
||||||
}
|
}
|
||||||
|
|
||||||
user.markModified('items achievements');
|
user.markModified('items achievements');
|
||||||
|
|||||||
Reference in New Issue
Block a user