mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 07:52:15 +00:00
feat(content): Harvest Feast 2021
This commit is contained in:
parent
1d2782c74e
commit
d20271e91f
4 changed files with 137 additions and 14 deletions
126
migrations/archive/2021/20211124_harvest_feast.js
Normal file
126
migrations/archive/2021/20211124_harvest_feast.js
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
const MIGRATION_NAME = '20211124_harvest_feast';
|
||||||
|
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 set = {};
|
||||||
|
let inc;
|
||||||
|
let push;
|
||||||
|
|
||||||
|
set.migration = MIGRATION_NAME;
|
||||||
|
|
||||||
|
if (typeof user.items.gear.owned.head_special_turkeyHelmGilded !== 'undefined') {
|
||||||
|
inc = {
|
||||||
|
'items.food.Pie_Base': 1,
|
||||||
|
'items.food.Pie_CottonCandyBlue': 1,
|
||||||
|
'items.food.Pie_CottonCandyPink': 1,
|
||||||
|
'items.food.Pie_Desert': 1,
|
||||||
|
'items.food.Pie_Golden': 1,
|
||||||
|
'items.food.Pie_Red': 1,
|
||||||
|
'items.food.Pie_Shade': 1,
|
||||||
|
'items.food.Pie_Skeleton': 1,
|
||||||
|
'items.food.Pie_Zombie': 1,
|
||||||
|
'items.food.Pie_White': 1,
|
||||||
|
}
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_turkeyArmorBase !== 'undefined') {
|
||||||
|
set['items.gear.owned.head_special_turkeyHelmGilded'] = false;
|
||||||
|
set['items.gear.owned.armor_special_turkeyArmorGilded'] = false;
|
||||||
|
set['items.gear.owned.back_special_turkeyTailGilded'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_turkeyHelmGilded',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.armor_special_turkeyArmorGilded',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.back_special_turkeyTailGilded',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (user.items && user.items.mounts && user.items.mounts['Turkey-Gilded']) {
|
||||||
|
set['items.gear.owned.head_special_turkeyHelmBase'] = false;
|
||||||
|
set['items.gear.owned.armor_special_turkeyArmorBase'] = false;
|
||||||
|
set['items.gear.owned.back_special_turkeyTailBase'] = false;
|
||||||
|
push = [
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.head_special_turkeyHelmBase',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.armor_special_turkeyArmorBase',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'marketGear',
|
||||||
|
path: 'gear.flat.back_special_turkeyTailBase',
|
||||||
|
_id: uuid(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (user.items && user.items.pets && user.items.pets['Turkey-Gilded']) {
|
||||||
|
set['items.mounts.Turkey-Gilded'] = true;
|
||||||
|
} else if (user.items && user.items.mounts && user.items.mounts['Turkey-Base']) {
|
||||||
|
set['items.pets.Turkey-Gilded'] = 5;
|
||||||
|
} else if (user.items && user.items.pets && user.items.pets['Turkey-Base']) {
|
||||||
|
set['items.mounts.Turkey-Base'] = true;
|
||||||
|
} else {
|
||||||
|
set['items.pets.Turkey-Base'] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||||
|
|
||||||
|
if (inc) {
|
||||||
|
return await User.update({_id: user._id}, {$inc: inc, $set: set}).exec();
|
||||||
|
} else if (push) {
|
||||||
|
return await User.update({_id: user._id}, {$set: set, $push: {pinnedItems: {$each: push}}}).exec();
|
||||||
|
} else {
|
||||||
|
return await User.update({_id: user._id}, {$set: set}).exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function processUsers () {
|
||||||
|
let query = {
|
||||||
|
migration: {$ne: MIGRATION_NAME},
|
||||||
|
'auth.timestamps.loggedin': {$gt: new Date('2021-11-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
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -391,7 +391,7 @@ export default {
|
||||||
return Object.values(this.viewOptions).some(g => g.selected);
|
return Object.values(this.viewOptions).some(g => g.selected);
|
||||||
},
|
},
|
||||||
imageURLs () {
|
imageURLs () {
|
||||||
if (!this.currentEvent || !this.currentEvent.season) {
|
if (!this.currentEvent || !this.currentEvent.season || this.currentEvent.season === 'thanksgiving') {
|
||||||
return {
|
return {
|
||||||
background: 'url(/static/npc/normal/time_travelers_background.png)',
|
background: 'url(/static/npc/normal/time_travelers_background.png)',
|
||||||
npc: this.closed ? 'url(/static/npc/normal/time_travelers_closed_banner.png)'
|
npc: this.closed ? 'url(/static/npc/normal/time_travelers_closed_banner.png)'
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ export const EVENTS = {
|
||||||
season: 'normal',
|
season: 'normal',
|
||||||
npcImageSuffix: '',
|
npcImageSuffix: '',
|
||||||
},
|
},
|
||||||
|
thanksgiving2021: {
|
||||||
|
start: '2021-11-24T08:00-05:00',
|
||||||
|
end: '2021-11-28T20:00-05:00',
|
||||||
|
season: 'thanksgiving',
|
||||||
|
npcImageSuffix: '_thanksgiving',
|
||||||
|
},
|
||||||
potions202111: {
|
potions202111: {
|
||||||
start: '2021-11-09T08:00-05:00',
|
start: '2021-11-09T08:00-05:00',
|
||||||
end: '2021-11-30T20:00-05:00',
|
end: '2021-11-30T20:00-05:00',
|
||||||
|
|
|
||||||
|
|
@ -144,19 +144,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().isBefore('2021-11-02T20:00-04:00')) {
|
if (moment().isBefore('2021-11-28T20:00-05:00')) {
|
||||||
user.migration = '20211028_habitoween_ladder';
|
user.migration = '20211124_harvest_feast';
|
||||||
user.items.pets['JackOLantern-Base'] = 5;
|
user.items.pets['Turkey-Base'] = 5;
|
||||||
user.items.food.Candy_Skeleton = 1;
|
user.items.currentPet = 'Turkey-Base';
|
||||||
user.items.food.Candy_Base = 1;
|
|
||||||
user.items.food.Candy_CottonCandyBlue = 1;
|
|
||||||
user.items.food.Candy_CottonCandyPink = 1;
|
|
||||||
user.items.food.Candy_Shade = 1;
|
|
||||||
user.items.food.Candy_White = 1;
|
|
||||||
user.items.food.Candy_Golden = 1;
|
|
||||||
user.items.food.Candy_Zombie = 1;
|
|
||||||
user.items.food.Candy_Desert = 1;
|
|
||||||
user.items.food.Candy_Red = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user.markModified('items achievements');
|
user.markModified('items achievements');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue