Fix
- Rewrite exports of debuffPotion functions
- Force clear debuffPotions in setDebuffPotionItems to make the same behavior as in develop branch
- Change class of debuffPotion items to shop_{key}
- Resolve lint warnings
This commit is contained in:
@@ -2,6 +2,7 @@ import each from 'lodash/each';
|
||||
import t from './translation';
|
||||
import { NotAuthorized } from '../libs/errors';
|
||||
import statsComputed from '../libs/statsComputed'; // eslint-disable-line import/no-cycle
|
||||
import setDebuffPotionItems from '../libs/setDebuffPotionItems'; // eslint-disable-line import/no-cycle
|
||||
import crit from '../fns/crit'; // eslint-disable-line import/no-cycle
|
||||
import updateStats from '../fns/updateStats';
|
||||
|
||||
@@ -287,6 +288,7 @@ spells.special = {
|
||||
if (!target.achievements.snowball) target.achievements.snowball = 0;
|
||||
target.achievements.snowball += 1;
|
||||
user.items.special.snowball -= 1;
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
salt: {
|
||||
@@ -300,8 +302,7 @@ spells.special = {
|
||||
cast (user) {
|
||||
user.stats.buffs.snowball = false;
|
||||
user.stats.gp -= 5;
|
||||
// Remove antidote from pinned items
|
||||
user.pinnedItems = user.pinnedItems.filter(item => !item.path.includes('spells.special.salt'));
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
spookySparkles: {
|
||||
@@ -320,6 +321,7 @@ spells.special = {
|
||||
if (!target.achievements.spookySparkles) target.achievements.spookySparkles = 0;
|
||||
target.achievements.spookySparkles += 1;
|
||||
user.items.special.spookySparkles -= 1;
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
opaquePotion: {
|
||||
@@ -333,8 +335,7 @@ spells.special = {
|
||||
cast (user) {
|
||||
user.stats.buffs.spookySparkles = false;
|
||||
user.stats.gp -= 5;
|
||||
// Remove antidote from pinned items
|
||||
user.pinnedItems = user.pinnedItems.filter(item => !item.path.includes('spells.special.opaquePotion'));
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
shinySeed: {
|
||||
@@ -353,6 +354,7 @@ spells.special = {
|
||||
if (!target.achievements.shinySeed) target.achievements.shinySeed = 0;
|
||||
target.achievements.shinySeed += 1;
|
||||
user.items.special.shinySeed -= 1;
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
petalFreePotion: {
|
||||
@@ -366,8 +368,7 @@ spells.special = {
|
||||
cast (user) {
|
||||
user.stats.buffs.shinySeed = false;
|
||||
user.stats.gp -= 5;
|
||||
// Remove antidote from pinned items
|
||||
user.pinnedItems = user.pinnedItems.filter(item => !item.path.includes('spells.special.petalFreePotion'));
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
seafoam: {
|
||||
@@ -386,6 +387,7 @@ spells.special = {
|
||||
if (!target.achievements.seafoam) target.achievements.seafoam = 0;
|
||||
target.achievements.seafoam += 1;
|
||||
user.items.special.seafoam -= 1;
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
sand: {
|
||||
@@ -399,7 +401,7 @@ spells.special = {
|
||||
cast (user) {
|
||||
user.stats.buffs.seafoam = false;
|
||||
user.stats.gp -= 5;
|
||||
user.pinnedItems = user.pinnedItems.filter(item => !item.path.includes('spells.special.sand'));
|
||||
setDebuffPotionItems(user);
|
||||
},
|
||||
},
|
||||
nye: {
|
||||
|
||||
@@ -46,10 +46,8 @@ import updateStore from './libs/updateStore';
|
||||
import inAppRewards from './libs/inAppRewards';
|
||||
|
||||
import setDebuffPotionItems from './libs/setDebuffPotionItems';
|
||||
api.setDebuffPotionItems = setDebuffPotionItems;
|
||||
|
||||
import getDebuffPotionItems from './libs/getDebuffPotionItems';
|
||||
api.getDebuffPotionItems = getDebuffPotionItems;
|
||||
|
||||
import uuid from './libs/uuid';
|
||||
|
||||
@@ -164,6 +162,9 @@ api.shops = shops;
|
||||
api.achievements = achievements;
|
||||
api.randomVal = randomVal;
|
||||
api.hasClass = hasClass;
|
||||
api.setDebuffPotionItems = setDebuffPotionItems;
|
||||
api.getDebuffPotionItems = getDebuffPotionItems;
|
||||
|
||||
|
||||
api.fns = {
|
||||
autoAllocate,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { TRANSFORMATION_DEBUFFS_LIST } from '../constants';
|
||||
|
||||
module.exports = function getDebuffPotionItems (user) {
|
||||
export default function getDebuffPotionItems (user) {
|
||||
const items = [];
|
||||
const userBuffs = user.stats.buffs;
|
||||
|
||||
if (user) {
|
||||
for (let key in TRANSFORMATION_DEBUFFS_LIST) {
|
||||
for (const key in TRANSFORMATION_DEBUFFS_LIST) {
|
||||
if (userBuffs[key]) {
|
||||
let debuff = TRANSFORMATION_DEBUFFS_LIST[key];
|
||||
const debuff = TRANSFORMATION_DEBUFFS_LIST[key];
|
||||
const item = {
|
||||
path: `spells.special.${debuff}`,
|
||||
type: 'debuffPotion',
|
||||
@@ -15,8 +15,7 @@ module.exports = function getDebuffPotionItems (user) {
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return items;
|
||||
}
|
||||
};
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
currency: 'gold',
|
||||
locked: false,
|
||||
purchaseType: 'debuffPotion',
|
||||
class: `inventory_special_${item.key}`,
|
||||
class: `shop_${item.key}`,
|
||||
path: `spells.special.${item.key}`,
|
||||
pinType: 'debuffPotion',
|
||||
};
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import getDebuffPotionItems from './getDebuffPotionItems';
|
||||
|
||||
function clearDebuffPotion (user) {
|
||||
return user.pinnedItems.filter(item => item.type !== 'debuffPotion');
|
||||
}
|
||||
|
||||
|
||||
export default function setDebuffPotionItems (user) {
|
||||
user.pinnedItems = clearDebuffPotion(user);
|
||||
|
||||
module.exports = function setDebuffPotionItems (user) {
|
||||
const debuffPotionItems = getDebuffPotionItems(user);
|
||||
|
||||
if (debuffPotionItems.length) {
|
||||
@@ -18,13 +24,7 @@ module.exports = function setDebuffPotionItems (user) {
|
||||
if (!isUserHaveDebuffInPinnedItems) {
|
||||
user.pinnedItems.push(...debuffPotionItems);
|
||||
}
|
||||
} else {
|
||||
user.pinnedItems = user.pinnedItems.filter(item => {
|
||||
return item.type !== 'debuffPotion';
|
||||
});
|
||||
}
|
||||
|
||||
return user;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user