mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Adventure Guide Prep (#11883)
* WIP(adventure): prereqs * WIP(drops): new modal * WIP(adventure): analytics fixes etc * feat(adventure): random egg+potion on 2nd task * fix(lint): noworkies * fix(modal): correctly construct classes * fix(tests): expectations and escape * fix(first-drops): address comments * fix(first-drops): don't give random drops until first drops * fix(drops): remove more Level 3 references * refactor(drops): no need for cloning * refactor(drops): unnecessary export * fix(first-drops): force sync * fix(first-drops): move to server * fix(first-drops): escape in case we get here with >0 items * fix(lint): line length * fix(pet-food): remove unused string
This commit is contained in:
26
website/common/script/fns/firstDrops.js
Normal file
26
website/common/script/fns/firstDrops.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { drops as eggs } from '../content/eggs';
|
||||
import { drops as hatchingPotions } from '../content/hatching-potions';
|
||||
import randomVal from '../libs/randomVal';
|
||||
|
||||
export default function firstDrops (user) {
|
||||
const eggDrop = randomVal(eggs);
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user