Files
habitica/website/common/script/fns/firstDrops.js
2024-06-11 18:19:21 +02:00

27 lines
946 B
JavaScript

import allEggs from '../content/eggs';
import { drops as hatchingPotions } from '../content/hatching-potions';
import randomVal from '../libs/randomVal';
export default function firstDrops (user) {
const eggDrop = randomVal(allEggs.drops);
const potionDrop = randomVal(hatchingPotions);
user.items.eggs = {
...user.items.eggs,
[eggDrop.key]: user.items.eggs[eggDrop.key] || 0,
};
user.items.eggs[eggDrop.key] += 1;
if (user.markModified) user.markModified('items.eggs');
user.items.hatchingPotions = {
...user.items.hatchingPotions,
[potionDrop.key]: user.items.hatchingPotions[potionDrop.key] || 0,
};
user.items.hatchingPotions[potionDrop.key] += 1;
if (user.markModified) user.markModified('items.hatchingPotions');
if (user.addNotification) user.addNotification('FIRST_DROPS', { egg: eggDrop.key, hatchingPotion: potionDrop.key });
return ({ egg: eggDrop.key, hatchingPotion: potionDrop.key });
}