quest unlock logic updates, starting on actually locking quests in shop
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import _mapValues from 'lodash/mapValues';
|
||||
import intersection from 'lodash/intersection';
|
||||
import keys from 'lodash/keys';
|
||||
import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import { BadRequest } from './errors';
|
||||
@@ -11,16 +9,13 @@ import isFreeRebirth from './isFreeRebirth';
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
|
||||
function lockQuest (quest, user) {
|
||||
// checks series quests, including Masterclasser
|
||||
|
||||
// checks series quests, including Masterclasser?
|
||||
if (quest.prereqQuests) {
|
||||
if (!user.achievements.quests) return true;
|
||||
const achievedQuestKeys = keys(user.achievements.quests);
|
||||
if (intersection(quest.prereqQuests, achievedQuestKeys) !== quest.prereqQuests) {
|
||||
return true;
|
||||
for (const prereq of quest.prereqQuests) {
|
||||
if (!user.achievements.quests[prereq]) return true;
|
||||
}
|
||||
}
|
||||
|
||||
// checks quest & user level against quest level
|
||||
if (quest.lvl && user.stats.lvl < quest.lvl) return true;
|
||||
|
||||
@@ -30,14 +25,12 @@ function lockQuest (quest, user) {
|
||||
&& quest.unlockCondition.incentiveThreshold
|
||||
&& user.loginIncentives < quest.unlockCondition.incentiveThreshold
|
||||
) return true;
|
||||
|
||||
if (user.achievements.quests) {
|
||||
return quest.previous
|
||||
&& !user.achievements.quests[quest.previous];
|
||||
}
|
||||
|
||||
// then if we've passed all the checks, at the end
|
||||
return false;
|
||||
// then if we've passed all the checks
|
||||
return quest.previous;
|
||||
}
|
||||
|
||||
function isItemSuggested (officialPinnedItems, itemInfo) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import content from '../../content/index';
|
||||
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
import { AbstractGemItemOperation } from './abstractBuyOperation';
|
||||
import getItemInfo from '../../libs/getItemInfo';
|
||||
|
||||
export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // eslint-disable-line import/prefer-default-export, max-len
|
||||
multiplePurchaseAllowed () { // eslint-disable-line class-methods-use-this
|
||||
@@ -33,6 +34,11 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli
|
||||
|
||||
const item = content.quests[key];
|
||||
|
||||
if (getItemInfo.locked) {
|
||||
throw new
|
||||
BadRequest(errorMessage(`Prerequisites for ${getItemInfo.text} not met.`));
|
||||
}
|
||||
|
||||
if (!item) throw new NotFound(errorMessage('questNotFound', { key }));
|
||||
|
||||
if (item.category === 'gold') {
|
||||
|
||||
Reference in New Issue
Block a user