mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
* 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
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import moment from 'moment';
|
|
|
|
const BEGIN_DATE = moment('2019-12-18');
|
|
|
|
// Only users that signed up after the BEGIN DATE should see the onboarding
|
|
export function hasActiveOnboarding (user) {
|
|
return BEGIN_DATE.isBefore(user.auth.timestamps.created);
|
|
}
|
|
|
|
export function hasCompletedOnboarding (user) {
|
|
return (
|
|
user.achievements.createdTask === true
|
|
&& user.achievements.completedTask === true
|
|
&& user.achievements.hatchedPet === true
|
|
&& user.achievements.fedPet === true
|
|
&& user.achievements.purchasedEquipment === true
|
|
);
|
|
}
|
|
|
|
export function onOnboardingComplete (user) {
|
|
// Award gold
|
|
user.stats.gp += 100;
|
|
}
|
|
|
|
// Add notification and awards (server)
|
|
export function checkOnboardingStatus (user, analytics) {
|
|
if (hasActiveOnboarding(user) && hasCompletedOnboarding(user) && user.addNotification) {
|
|
user.addNotification('ONBOARDING_COMPLETE');
|
|
if (analytics) {
|
|
analytics.track('onboarding complete', {
|
|
uuid: user._id,
|
|
hitType: 'event',
|
|
category: 'behavior',
|
|
});
|
|
}
|
|
onOnboardingComplete(user);
|
|
}
|
|
}
|