mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Merge branch 'develop' into sabrecat/teams-rebase
This commit is contained in:
@@ -42,6 +42,18 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli
|
||||
this.canUserPurchase(user, item);
|
||||
}
|
||||
|
||||
canUserPurchase (user, item) {
|
||||
if (item && item.prereqQuests) {
|
||||
for (const prereq of item.prereqQuests) {
|
||||
if (!user.achievements.quests[prereq]) {
|
||||
throw new NotAuthorized(this.i18n('mustComplete', { quest: prereq }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.canUserPurchase(user, item);
|
||||
}
|
||||
|
||||
async executeChanges (user, item, req) {
|
||||
if (
|
||||
!user.items.quests[item.key]
|
||||
|
||||
@@ -46,20 +46,22 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation { // es
|
||||
throw new NotAuthorized(this.i18n('questNotGoldPurchasable', { key }));
|
||||
}
|
||||
|
||||
this.checkPrerequisites(user, key);
|
||||
|
||||
this.canUserPurchase(user, item);
|
||||
}
|
||||
|
||||
checkPrerequisites (user, questKey) {
|
||||
const item = content.quests[questKey];
|
||||
if (questKey === 'lostMasterclasser1' && !this.userAbleToStartMasterClasser(user)) {
|
||||
canUserPurchase (user, item) {
|
||||
if (this.getItemKey() === 'lostMasterclasser1' && !this.userAbleToStartMasterClasser(user)) {
|
||||
throw new NotAuthorized(this.i18n('questUnlockLostMasterclasser'));
|
||||
}
|
||||
|
||||
if (item && item.previous && !user.achievements.quests[item.previous]) {
|
||||
throw new NotAuthorized(this.i18n('mustComplete', { quest: item.previous }));
|
||||
if (item && item.prereqQuests) {
|
||||
for (const prereq of item.prereqQuests) {
|
||||
if (!user.achievements.quests[prereq]) {
|
||||
throw new NotAuthorized(this.i18n('mustComplete', { quest: prereq }));
|
||||
}
|
||||
}
|
||||
}
|
||||
super.canUserPurchase(user, item);
|
||||
}
|
||||
|
||||
executeChanges (user, item, req) {
|
||||
|
||||
Reference in New Issue
Block a user