mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Fix buying some items
This commit is contained in:
committed by
Sabe Jones
parent
bca3e96e9c
commit
fe2c02679e
@@ -53,7 +53,8 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli
|
||||
}
|
||||
|
||||
const matchers = getScheduleMatchingGroup(`${item.category}Quests`);
|
||||
if (matchers.match(item.key)) {
|
||||
console.log(matchers);
|
||||
if (!matchers.match(item.key)) {
|
||||
throw new NotAuthorized(this.i18n('notAvailable', { key: item.key }));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,6 @@ async function purchaseItem (user, item, price, type, key) {
|
||||
if (user.markModified) user.markModified('items.gear.owned');
|
||||
} else if (type === 'bundles') {
|
||||
const subType = item.type;
|
||||
const matchers = getScheduleMatchingGroup('bundles');
|
||||
if (!matchers.match(item.key)) {
|
||||
throw new NotAuthorized(i18n.t('notAvailable', { key: item.key }));
|
||||
}
|
||||
forEach(item.bundleKeys, bundledKey => {
|
||||
if (!user.items[subType][bundledKey] || user.items[subType][bundledKey] < 0) {
|
||||
user.items[subType][bundledKey] = 0;
|
||||
@@ -101,7 +97,7 @@ export default async function purchase (user, req = {}, analytics) {
|
||||
|
||||
const { price, item } = getItemAndPrice(user, type, key, req);
|
||||
|
||||
if (item.type === 'hatchingPotion' && item.premium === true) {
|
||||
if (type === 'hatchingPotions' && item.premium === true) {
|
||||
const matchers = getScheduleMatchingGroup('premiumHatchingPotions');
|
||||
if (!matchers.match(item.key)) {
|
||||
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
||||
@@ -111,6 +107,11 @@ export default async function purchase (user, req = {}, analytics) {
|
||||
if (!matchers.match(item.set)) {
|
||||
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
||||
}
|
||||
} else if (type === 'bundles') {
|
||||
const matchers = getScheduleMatchingGroup('bundles');
|
||||
if (!matchers.match(item.key)) {
|
||||
throw new NotAuthorized(i18n.t('notAvailable', { key: item.key }));
|
||||
}
|
||||
} else if (!item.canBuy(user)) {
|
||||
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { // eslint-disable-line import/no-cycle
|
||||
model as Group,
|
||||
TAVERN_ID as tavernId,
|
||||
} from '../models/group';
|
||||
import common from '../../common';
|
||||
import { REPEATING_EVENTS } from '../../common/script/content/constants';
|
||||
import { getCurrentGalaEvent } from '../../common/script/content/constants/schedule';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user