fortify potion + fix pinning check (#9089)

This commit is contained in:
negue
2017-09-28 01:06:07 +02:00
committed by Keith Holliday
parent ee6ceecc35
commit f4bf2df4a9
4 changed files with 34 additions and 8 deletions

View File

@@ -485,7 +485,10 @@ export default {
}), }),
}); });
let specialItems = []; let specialItems = [{
...getItemInfo(this.user, 'fortify'),
showCount: false,
}];
if (this.user.purchased.plan.customerId) { if (this.user.purchased.plan.customerId) {
let gemItem = getItemInfo(this.user, 'gem'); let gemItem = getItemInfo(this.user, 'gem');

View File

@@ -7,6 +7,7 @@ import hourglassPurchaseOp from 'common/script/ops/hourglassPurchase';
import sellOp from 'common/script/ops/sell'; import sellOp from 'common/script/ops/sell';
import unlockOp from 'common/script/ops/unlock'; import unlockOp from 'common/script/ops/unlock';
import buyArmoire from 'common/script/ops/buyArmoire'; import buyArmoire from 'common/script/ops/buyArmoire';
import rerollOp from 'common/script/ops/reroll';
export function buyItem (store, params) { export function buyItem (store, params) {
const user = store.state.user.data; const user = store.state.user.data;
@@ -87,6 +88,15 @@ export function genericPurchase (store, params) {
axios.post('/api/v3/user/buy-armoire'); axios.post('/api/v3/user/buy-armoire');
return; 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 'potion':
case 'marketGear': case 'marketGear':
return buyItem(store, params); return buyItem(store, params);
@@ -99,8 +109,6 @@ export function genericPurchase (store, params) {
default: default:
if (params.pinType === 'quests' && params.currency === 'gold') { if (params.pinType === 'quests' && params.currency === 'gold') {
return buyQuestItem(store, params); return buyQuestItem(store, params);
} else if (params.key === 'rebirth_orb') {
return store.dispatch('user:rebirth');
} else if (params.currency === 'hourglasses') { } else if (params.currency === 'hourglasses') {
return purchaseHourglassItem(store, params); return purchaseHourglassItem(store, params);
} else { } else {

View File

@@ -299,6 +299,20 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
}; };
break; 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) { if (itemInfo) {

View File

@@ -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 * @returns {boolean} TRUE added the item / FALSE removed it
*/ */
function togglePinnedItem (user, {item, type, path}, req = {}) { function togglePinnedItem (user, {item, type, path}, req = {}) {
let arrayToChange; let arrayToChange;
let officialPinnedItems = getOfficialPinnedItems(user);
if (!path) { if (!path) {
// If path isn't passed it means an item was passed // 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 { } else {
if (!item) { if (!item) {
item = get(content, path); item = get(content, path);
} }
if (!item) { if (!item && PATHS_WITHOUT_ITEM.indexOf(path) === -1) {
// path not exists in our content structure // path not exists in our content structure
throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language)); throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language));
} }
// check if item exists & valid to be pinned // 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)); throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
} }
let officialPinnedItems = getOfficialPinnedItems(user);
let isOfficialPinned = officialPinnedItems.find(officialPinnedItem => { let isOfficialPinned = officialPinnedItems.find(officialPinnedItem => {
return officialPinnedItem.path === path; return officialPinnedItem.path === path;
}) !== undefined; }) !== undefined;