From c21726ec61b53c6f9ad13653905a4f518ce84d02 Mon Sep 17 00:00:00 2001 From: Mateus Etto Date: Sat, 31 Mar 2018 08:34:39 -0300 Subject: [PATCH] No Ethereal Surge on Mages (#10121) * problem location identified (breaks code) * problem identification notes * Add class checking to ES (does not yet notify user) * Add error message * Add .gitattributes Attempting to fix line ending disaster * package stuff so I can see what's broken * add reminder and hopefully fix gitattributes * Fix lint errors * Redo surge fail notifs * exterminate rogue comment, fix gitattributes * Remove unused import As per @paglias' request. * fix(lint): remove extraneous expression * Delete .gitattributes * Fix skill key surge -> mpheal * Show notification only when there are mages in party * Fix notification being too big and appearing outside the notification div * Remove unused code * Only show the notification on parties with 2 or more mages The caster is a mage, so certainly at least 1 mage will be counted. * Automated test: mpheal does not heal other mages * Fix lint error * Fix typo in test description * Increase performance of test * Using target instead of requestion partyMembers again * Rename variable 'party' to 'partyMembers' * Update strings in English * spell -> Skill --- .../user/POST-user_class_cast_spellId.test.js | 29 +++++++++++++++++++ .../components/snackbars/notification.vue | 2 +- website/client/mixins/spells.js | 26 ++++++++++++++--- website/common/locales/en/spells.json | 3 +- website/common/script/content/spells.js | 2 +- 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/test/api/v3/integration/user/POST-user_class_cast_spellId.test.js b/test/api/v3/integration/user/POST-user_class_cast_spellId.test.js index bf7d4fcf1a..a141a31145 100644 --- a/test/api/v3/integration/user/POST-user_class_cast_spellId.test.js +++ b/test/api/v3/integration/user/POST-user_class_cast_spellId.test.js @@ -187,6 +187,35 @@ describe('POST /user/class/cast/:spellId', () => { expect(group.chat[0].uuid).to.equal('system'); }); + it('Ethereal Surge does not recover mp of other mages', async () => { + let group = await createAndPopulateGroup({ + groupDetails: { type: 'party', privacy: 'private' }, + members: 4, + }); + + let promises = []; + promises.push(group.groupLeader.update({'stats.mp': 200, 'stats.class': 'wizard', 'stats.lvl': 20})); + promises.push(group.members[0].update({'stats.mp': 0, 'stats.class': 'warrior', 'stats.lvl': 20})); + promises.push(group.members[1].update({'stats.mp': 0, 'stats.class': 'wizard', 'stats.lvl': 20})); + promises.push(group.members[2].update({'stats.mp': 0, 'stats.class': 'rogue', 'stats.lvl': 20})); + promises.push(group.members[3].update({'stats.mp': 0, 'stats.class': 'healer', 'stats.lvl': 20})); + await Promise.all(promises); + + await group.groupLeader.post('/user/class/cast/mpheal'); + + promises = []; + promises.push(group.members[0].sync()); + promises.push(group.members[1].sync()); + promises.push(group.members[2].sync()); + promises.push(group.members[3].sync()); + await Promise.all(promises); + + expect(group.members[0].stats.mp).to.be.greaterThan(0); // warrior + expect(group.members[1].stats.mp).to.equal(0); // wizard + expect(group.members[2].stats.mp).to.be.greaterThan(0); // rogue + expect(group.members[3].stats.mp).to.be.greaterThan(0); // healer + }); + it('cast bulk', async () => { let { group, groupLeader } = await createAndPopulateGroup({ groupDetails: { type: 'party', privacy: 'private' }, diff --git a/website/client/components/snackbars/notification.vue b/website/client/components/snackbars/notification.vue index 6302b7c422..ec544e6c93 100644 --- a/website/client/components/snackbars/notification.vue +++ b/website/client/components/snackbars/notification.vue @@ -59,7 +59,7 @@ transition(name="fade") .text { text-align: center; - padding: .5em; + padding: .5em 1.5em; } .svg-icon { diff --git a/website/client/mixins/spells.js b/website/client/mixins/spells.js index 9d597292ed..6789486537 100644 --- a/website/client/mixins/spells.js +++ b/website/client/mixins/spells.js @@ -32,10 +32,11 @@ export default { return this.castEnd(party, spell.target); } - let party = this.$store.state.partyMembers; - party = isArray(party) ? party : []; - party = party.concat(this.user); - this.castEnd(party, spell.target); + let partyMembers = this.$store.state.partyMembers.data; + if (!isArray(partyMembers)) { + partyMembers = [this.user]; + } + this.castEnd(partyMembers, spell.target); } else if (spell.target === 'tasks') { let userTasks = this.$store.state.tasks.data; // exclude rewards @@ -129,6 +130,23 @@ export default { this.markdown(msg); // @TODO: mardown directive? + + // If using mpheal and there are other mages in the party, show extra notification + if (type === 'party' && spell.key === 'mpheal') { + // Counting mages + let magesCount = 0; + for (let i = 0; i < target.length; i++) { + if (target[i].stats.class === 'wizard') { + magesCount++; + } + } + // If there are mages, show message telling that the mpheal don't work on other mages + // The count must be bigger than 1 because the user casting the spell is a mage + if (magesCount > 1) { + this.markdown(this.$t('spellWizardNoEthOnMage')); + } + } + // @TODO: if (!beforeQuestProgress) return apiResult; let questProgress = this.questProgress() - beforeQuestProgress; diff --git a/website/common/locales/en/spells.json b/website/common/locales/en/spells.json index 4cf2d82af7..773e3301ba 100644 --- a/website/common/locales/en/spells.json +++ b/website/common/locales/en/spells.json @@ -3,7 +3,8 @@ "spellWizardFireballNotes": "You summon XP and deal fiery damage to Bosses! (Based on: INT)", "spellWizardMPHealText": "Ethereal Surge", - "spellWizardMPHealNotes": "You sacrifice mana so the rest of your Party gains MP! (Based on: INT)", + "spellWizardMPHealNotes": "You sacrifice Mana so the rest of your Party, except Mages, gains MP! (Based on: INT)", + "spellWizardNoEthOnMage": "Your Skill backfires when mixed with another's magic. Only non-Mages gain MP.", "spellWizardEarthText": "Earthquake", "spellWizardEarthNotes": "Your mental power shakes the earth and buffs your Party's Intelligence! (Based on: Unbuffed INT)", diff --git a/website/common/script/content/spells.js b/website/common/script/content/spells.js index 84bf7be5cd..c4585afc1b 100644 --- a/website/common/script/content/spells.js +++ b/website/common/script/content/spells.js @@ -62,7 +62,7 @@ spells.wizard = { cast (user, target) { each(target, (member) => { let bonus = statsComputed(user).int; - if (user._id !== member._id) { + if (user._id !== member._id && member.stats.class !== 'wizard') { member.stats.mp += Math.ceil(diminishingReturns(bonus, 25, 125)); } });