habitica-self-host/website/common/script/content/quests.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

import defaults from 'lodash/defaults';
import each from 'lodash/each';
2022-01-27 21:59:29 +00:00
// import find from 'lodash/find';
// import moment from 'moment';
import sortBy from 'lodash/sortBy';
import t from './translation';
import {
USER_CAN_OWN_QUEST_CATEGORIES,
2022-01-27 21:59:29 +00:00
QUEST_GENERIC,
QUEST_MASTERCLASSER,
QUEST_PETS,
QUEST_POTIONS,
QUEST_SEASONAL,
QUEST_SERIES,
2022-01-27 21:59:29 +00:00
QUEST_TIME_TRAVEL,
QUEST_WORLD,
} from './constants';
2019-10-08 14:57:10 +00:00
const userCanOwnQuestCategories = USER_CAN_OWN_QUEST_CATEGORIES;
2022-01-27 21:59:29 +00:00
const questGeneric = QUEST_GENERIC;
const questMasterclasser = QUEST_MASTERCLASSER;
const questPets = QUEST_PETS;
const questPotions = QUEST_POTIONS;
const questSeasonal = QUEST_SEASONAL;
const questSeries = QUEST_SERIES;
2022-01-27 21:59:29 +00:00
const questTimeTravel = QUEST_TIME_TRAVEL;
const questWorld = QUEST_WORLD;
2022-01-27 21:59:29 +00:00
// need to reconstruct a flat list from these by --
// check for a lodash object tht will combine multiple objects into one obects
// I've added an additional ayer to the tree that the api and the rest of the
// code in this file are not expecting hence api.quests not being found
const quests = questGeneric.concat(
2022-01-27 21:59:29 +00:00
questMasterclasser,
questPets,
questPotions,
questSeasonal,
questSeries,
2022-01-27 21:59:29 +00:00
questTimeTravel,
questWorld,
);
2022-01-27 21:59:29 +00:00
console.log(quests);
each(quests, (v, key) => {
defaults(v, {
key,
canBuy () {
return true;
},
});
2019-10-09 14:51:17 +00:00
const b = v.boss;
if (b) {
defaults(b, {
str: 1,
def: 1,
});
if (b.rage) {
2019-10-09 18:08:36 +00:00
defaults(b.rage, {
title: t('rage'),
description: t('bossRageDescription'),
});
}
}
});
2019-10-08 14:57:10 +00:00
const questsByLevel = sortBy(quests, quest => quest.lvl || 0);
2019-10-01 15:53:48 +00:00
export {
quests,
questsByLevel,
userCanOwnQuestCategories,
};