feat(chat): veteran awards

This commit is contained in:
SabreCat
2023-07-31 16:38:30 -05:00
parent 712205d253
commit 0140b9beb7
5 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20230801_veteran_pet_ladder';
import { model as User } from '../../../website/server/models/user';
const progressCount = 1000;
let count = 0;
async function updateUser (user) {
count++;
const set = {};
let push = { notifications: { $each: [] }};
set.migration = MIGRATION_NAME;
if (user.items.pets['Fox-Veteran']) {
set['items.pets.Dragon-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_dragon',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Dragon.',
destination: '/inventory/stable',
},
seen: false,
});
} else if (user.items.pets['Bear-Veteran']) {
set['items.pets.Fox-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_fox',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Fox.',
destination: '/inventory/stable',
},
seen: false,
});
} else if (user.items.pets['Lion-Veteran']) {
set['items.pets.Bear-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_bear',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Bear.',
destination: '/inventory/stable',
},
seen: false,
});
} else if (user.items.pets['Tiger-Veteran']) {
set['items.pets.Lion-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_lion',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Lion.',
destination: '/inventory/stable',
},
seen: false,
});
} else if (user.items.pets['Wolf-Veteran']) {
set['items.pets.Tiger-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_tiger',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Tiger.',
destination: '/inventory/stable',
},
seen: false,
});
} else {
set['items.pets.Wolf-Veteran'] = 5;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'icon_pet_veteran_wolf',
title: 'Youve received a Veteran Pet!',
text: 'To commemorate being here for a new era of Habitca, weve awarded you a Veteran Wolf.',
destination: '/inventory/stable',
},
seen: false,
});
}
if (user.contributor.level > 0) {
set['items.gear.owned.armor_special_heroicTunic'] = true;
set['items.gear.owned.back_special_heroicAureole'] = true;
set['items.gear.owned.head_special_heroicCirclet'] = true;
push.notifications.$each.push({
type: 'ITEM_RECEIVED',
data: {
icon: 'heroic_set_icon',
title: 'Youve received the Heroic Set!',
text: 'To commemorate your hard work as a contributor, weve awarded you the Heroic Circlet, Heroic Aureole, and Heroic Tunic.',
destination: '/inventory/equipment',
},
seen: false,
});
}
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await User.update({_id: user._id}, {$set: set, $push: push}).exec();
}
export default async function processUsers () {
let query = {
migration: {$ne: MIGRATION_NAME},
'auth.timestamps.loggedin': { $gt: new Date('2023-07-01') },
};
const fields = {
_id: 1,
items: 1,
migration: 1,
contributor: 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

@@ -19,6 +19,7 @@
"veteranLion": "Veteran Lion",
"veteranBear": "Veteran Bear",
"veteranFox": "Veteran Fox",
"veteranDragon": "Veteran Dragon",
"cerberusPup": "Cerberus Pup",
"hydra": "Hydra",
"mantisShrimp": "Mantis Shrimp",

View File

@@ -27,6 +27,7 @@ const armor = {
1: contributorGear.armorSpecial1,
2: backerGear.armorSpecial2,
takeThis: takeThisGear.armorSpecialTakeThis,
heroicTunic: contributorGear.armorSpecialHeroicTunic,
finnedOceanicArmor: {
text: t('armorSpecialFinnedOceanicArmorText'),
notes: t('armorSpecialFinnedOceanicArmorNotes', { str: 15 }),
@@ -868,6 +869,7 @@ const back = {
wondercon_red: wonderconGear.backSpecialWonderconRed, // eslint-disable-line camelcase
wondercon_black: wonderconGear.backSpecialWonderconBlack, // eslint-disable-line camelcase
takeThis: takeThisGear.backSpecialTakeThis,
heroicAureole: contributorGear.backSpecialHeroicAureole,
snowdriftVeil: {
text: t('backSpecialSnowdriftVeilText'),
notes: t('backSpecialSnowdriftVeilNotes'),
@@ -1204,6 +1206,7 @@ const head = {
1: contributorGear.headSpecial1,
2: backerGear.headSpecial2,
takeThis: takeThisGear.headSpecialTakeThis,
heroicCirclet: contributorGear.headSpecialHeroicCirclet,
fireCoralCirclet: {
text: t('headSpecialFireCoralCircletText'),
notes: t('headSpecialFireCoralCircletNotes', { per: 15 }),

View File

@@ -66,10 +66,46 @@ const weaponSpecialCritical = {
},
};
const armorSpecialHeroicTunic = {
text: t('armorSpecialHeroicTunicText'),
notes: t('armorSpecialHeroicTunicNotes', { attrs: 7 }),
con: 7,
str: 7,
per: 7,
int: 7,
value: 175,
canOwn: ownsItem('armor_special_heroicTunic'),
};
const backSpecialHeroicAureole = {
text: t('backSpecialHeroicAureoleText'),
notes: t('backSpecialHeroicAureoleNotes', { attrs: 7 }),
con: 7,
str: 7,
per: 7,
int: 7,
value: 175,
canOwn: ownsItem('armor_special_heroicAureole'),
};
const headSpecialHeroicCirclet = {
text: t('headSpecialHeroicCircletText'),
notes: t('headSpecialHeroicCircletNotes', { attrs: 7 }),
con: 7,
str: 7,
per: 7,
int: 7,
value: 175,
canOwn: ownsItem('head_special_heroicCirclet'),
};
export {
armorSpecial1,
headSpecial1,
shieldSpecial1,
weaponSpecial1,
weaponSpecialCritical,
armorSpecialHeroicTunic,
backSpecialHeroicAureole,
headSpecialHeroicCirclet,
};

View File

@@ -92,6 +92,7 @@ const canFindSpecial = {
'Lion-Veteran': false,
'Bear-Veteran': false,
'Fox-Veteran': false,
'Dragon-Veteran': false,
// Thanksgiving pet ladder
'Turkey-Base': false,
@@ -181,6 +182,7 @@ const specialPets = {
'Gryphon-Gryphatrice': 'gryphatrice',
'Gryphatrice-Jubilant': 'jubilantGryphatrice',
'JackOLantern-RoyalPurple': 'royalPurpleJackolantern',
'Dragon-Veteran': 'veteranDragon',
};
const specialMounts = {