feat(event): New Year's Eve 2021

This commit is contained in:
SabreCat
2021-12-30 13:34:04 -06:00
parent bcfea31ffb
commit 5973bca327
7 changed files with 153 additions and 9 deletions

View File

@@ -0,0 +1,135 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20211230_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_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('2021-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
}
};

View File

@@ -18,7 +18,7 @@ function setUpServer () {
setUpServer();
// Replace this with your migration
const processUsers = require().default;
const processUsers = require('./archive/2021/20211230_nye').default;
processUsers()
.then(() => {

View File

@@ -423,7 +423,10 @@
"weaponSpecialWinter2022MageText": "Pomegranate Staff",
"weaponSpecialWinter2022MageNotes": "The berries on this staff contain an ancient magic to be wielded in winter. Increases Intelligence by <%= int %> and Perception by <%= per %>. Limited Edition 2021-2022 Winter Gear.",
"weaponSpecialWinter2022HealerText": "Crystalline Ice Wand",
"weaponSpecialWinter2022HealerNotes": "Touch this solid-water implement to a friend's neck and they'll jump out of their chair! But they'll feel better afterward. Hopefully.Increases Intelligence by <%= int %>. Limited Edition 2021-2022 Winter Gear.",
"weaponSpecialWinter2022HealerNotes": "Touch this solid-water implement to a friend's neck and they'll jump out of their chair! But they'll feel better afterward. Hopefully. Increases Intelligence by <%= int %>. Limited Edition 2021-2022 Winter Gear.",
"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.",
"weaponMystery201411Text": "Pitchfork of Feasting",
"weaponMystery201411Notes": "Stab your enemies or dig in to your favorite foods - this versatile pitchfork does it all! Confers no benefit. November 2014 Subscriber Item.",

View File

@@ -1768,6 +1768,12 @@ const head = {
winter2022Healer: {
set: 'winter2022IceCrystalHealerSet',
},
nye2021: {
text: t('headSpecialNye2021Text'),
notes: t('headSpecialNye2021Notes'),
value: 0,
canOwn: ownsItem('head_special_nye2021'),
},
};
const headStats = {

View File

@@ -111,7 +111,7 @@ api.cardTypes = {
nye: {
key: 'nye',
messageOptions: 5,
yearRound: moment().isBefore('2021-01-02'),
yearRound: moment().isBefore('2022-01-02T20:00-04:00'),
},
thankyou: {
key: 'thankyou',

View File

@@ -289,7 +289,7 @@ spells.special = {
target: 'user',
notes: t('spellSpecialSnowballAuraNotes'),
canOwn () {
return false;
return moment().isBetween('2021-12-30T08:00-04:00', EVENTS.winter2022.end);
},
cast (user, target, req) {
if (!user.items.special.snowball) throw new NotAuthorized(t('spellNotOwned')(req.language));
@@ -435,7 +435,7 @@ spells.special = {
target: 'user',
notes: t('nyeCardNotes'),
canOwn () {
return false;
return moment().isBetween('2021-12-30T08:00-04:00', '2022-01-02T20:00-04:00');
},
cast (user, target) {
if (user === target) {

View File

@@ -144,10 +144,10 @@ function _setUpNewUser (user) {
user.items.quests.dustbunnies = 1;
user.purchased.background.violet = true;
user.preferences.background = 'violet';
if (moment().isBefore('2021-11-28T20:00-05:00')) {
user.migration = '20211124_harvest_feast';
user.items.pets['Turkey-Base'] = 5;
user.items.currentPet = 'Turkey-Base';
if (moment().isBefore('2022-01-02T20:00-05:00')) {
user.migration = '20211213_nye';
user.items.gear.owned.head_special_nye = true;
user.items.gear.equipped.head = 'head_special_nye';
}
user.markModified('items achievements');