mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fortify potion + fix pinning check (#9089)
This commit is contained in:
@@ -485,7 +485,10 @@ export default {
|
||||
}),
|
||||
});
|
||||
|
||||
let specialItems = [];
|
||||
let specialItems = [{
|
||||
...getItemInfo(this.user, 'fortify'),
|
||||
showCount: false,
|
||||
}];
|
||||
|
||||
if (this.user.purchased.plan.customerId) {
|
||||
let gemItem = getItemInfo(this.user, 'gem');
|
||||
|
||||
@@ -7,6 +7,7 @@ import hourglassPurchaseOp from 'common/script/ops/hourglassPurchase';
|
||||
import sellOp from 'common/script/ops/sell';
|
||||
import unlockOp from 'common/script/ops/unlock';
|
||||
import buyArmoire from 'common/script/ops/buyArmoire';
|
||||
import rerollOp from 'common/script/ops/reroll';
|
||||
|
||||
export function buyItem (store, params) {
|
||||
const user = store.state.user.data;
|
||||
@@ -87,6 +88,15 @@ export function genericPurchase (store, params) {
|
||||
|
||||
axios.post('/api/v3/user/buy-armoire');
|
||||
return;
|
||||
case 'fortify': {
|
||||
let rerollResult = rerollOp(store.state.user.data);
|
||||
|
||||
axios.post('/api/v3/user/reroll');
|
||||
|
||||
return rerollResult;
|
||||
}
|
||||
case 'rebirth_orb':
|
||||
return store.dispatch('user:rebirth');
|
||||
case 'potion':
|
||||
case 'marketGear':
|
||||
return buyItem(store, params);
|
||||
@@ -99,8 +109,6 @@ export function genericPurchase (store, params) {
|
||||
default:
|
||||
if (params.pinType === 'quests' && params.currency === 'gold') {
|
||||
return buyQuestItem(store, params);
|
||||
} else if (params.key === 'rebirth_orb') {
|
||||
return store.dispatch('user:rebirth');
|
||||
} else if (params.currency === 'hourglasses') {
|
||||
return purchaseHourglassItem(store, params);
|
||||
} else {
|
||||
|
||||
@@ -299,6 +299,20 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
};
|
||||
break;
|
||||
}
|
||||
case 'fortify': {
|
||||
itemInfo = {
|
||||
key: 'fortify',
|
||||
purchaseType: 'fortify',
|
||||
class: 'inventory_special_fortify',
|
||||
text: i18n.t('fortifyName'),
|
||||
notes: i18n.t('fortifyPop'),
|
||||
value: 4,
|
||||
currency: 'gems',
|
||||
path: 'special.fortify',
|
||||
pinType: 'fortify',
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemInfo) {
|
||||
|
||||
@@ -116,28 +116,31 @@ function removePinnedItemsByOwnedGear (user) {
|
||||
});
|
||||
}
|
||||
|
||||
const PATHS_WITHOUT_ITEM = ['special.gems', 'special.rebirth_orb', 'special.fortify'];
|
||||
|
||||
/**
|
||||
* @returns {boolean} TRUE added the item / FALSE removed it
|
||||
*/
|
||||
function togglePinnedItem (user, {item, type, path}, req = {}) {
|
||||
let arrayToChange;
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
if (!path) {
|
||||
// If path isn't passed it means an item was passed
|
||||
path = getItemInfo(user, type, item, req.language).path;
|
||||
path = getItemInfo(user, type, item, officialPinnedItems, req.language).path;
|
||||
} else {
|
||||
if (!item) {
|
||||
item = get(content, path);
|
||||
}
|
||||
|
||||
if (!item) {
|
||||
if (!item && PATHS_WITHOUT_ITEM.indexOf(path) === -1) {
|
||||
// path not exists in our content structure
|
||||
|
||||
throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language));
|
||||
}
|
||||
|
||||
// check if item exists & valid to be pinned
|
||||
getItemInfo(user, type, item, req.language);
|
||||
getItemInfo(user, type, item, officialPinnedItems, req.language);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +148,6 @@ function togglePinnedItem (user, {item, type, path}, req = {}) {
|
||||
throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
|
||||
}
|
||||
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
let isOfficialPinned = officialPinnedItems.find(officialPinnedItem => {
|
||||
return officialPinnedItem.path === path;
|
||||
}) !== undefined;
|
||||
|
||||
Reference in New Issue
Block a user