mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
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:
@@ -16,7 +16,7 @@ describe('setDebuffPotionItems', () => {
|
||||
user.stats.buffs.spookySparkles = true;
|
||||
const previousPinnedItemsLength = user.pinnedItems.length;
|
||||
|
||||
let result = setDebuffPotionItems(user);
|
||||
const result = setDebuffPotionItems(user);
|
||||
|
||||
expect(result.pinnedItems.length).to.be.greaterThan(previousPinnedItemsLength);
|
||||
});
|
||||
|
||||
@@ -335,7 +335,6 @@ import BuyQuestModal from '@/components/shops/quests/buyQuestModal.vue';
|
||||
import notifications from '@/mixins/notifications';
|
||||
import { shouldDo } from '@/../../common/script/cron';
|
||||
import inAppRewards from '@/../../common/script/libs/inAppRewards';
|
||||
import spells from '@/../../common/script/content/spells';
|
||||
import taskDefaults from '@/../../common/script/libs/taskDefaults';
|
||||
|
||||
import {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '../models/group';
|
||||
import apiError from './apiError';
|
||||
|
||||
const partyMembersFields = 'profile.name stats achievements items.special notifications flags';
|
||||
const partyMembersFields = 'profile.name stats achievements items.special notifications flags pinnedItems';
|
||||
// Excluding notifications and flags from the list of public fields to return.
|
||||
const partyMembersPublicFields = 'profile.name stats achievements items.special';
|
||||
|
||||
@@ -98,7 +98,7 @@ async function castPartySpell (req, party, partyMembers, user, spell, quantity =
|
||||
return partyMembers;
|
||||
}
|
||||
|
||||
async function castUserSpell (res, req, party, partyMember, targetId, user, spell, quantity = 1) {
|
||||
async function castUserSpell (res, req, party, partyMembers, targetId, user, spell, quantity = 1) {
|
||||
if (!party && (!targetId || user._id === targetId)) {
|
||||
partyMembers = user; // eslint-disable-line no-param-reassign
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user