Skip to content

Commit

Permalink
#331 Sum AOE magic effect (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyvg authored Aug 13, 2024
1 parent 652da8e commit 9f146e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
13 changes: 12 additions & 1 deletion src/arena/LogService/utils/format-action.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import type { SuccessArgs } from '@/arena/Constuructors/types';
import { getWeaponAction } from '@/arena/MiscService';
import { floatNumber } from '@/utils/floatNumber';

export function formatAction(msgObj: SuccessArgs): string {
if (msgObj.msg) {
return msgObj.msg(msgObj);
}

const calculateEffect = () => {
if (msgObj.expArr.length) {
return msgObj.expArr.reduce((effect, { val }) => {
return floatNumber(effect + (val || 0));
}, msgObj.effect);
}

return msgObj.effect;
};

switch (msgObj.actionType) {
case 'heal':
return `Игрок *${msgObj.target}* был вылечен 🤲 на *💖${msgObj.effect}*`;
Expand All @@ -15,7 +26,7 @@ export function formatAction(msgObj: SuccessArgs): string {
case 'dmg-magic':
case 'dmg-magic-long':
case 'aoe-dmg-magic':
return `*${msgObj.initiator}* сотворил _${msgObj.action}_ на *${msgObj.target}* нанеся ${msgObj.effect} урона`;
return `*${msgObj.initiator}* сотворил _${msgObj.action}_ на *${msgObj.target}* нанеся ${calculateEffect()} урона`;
case 'magic':
case 'magic-long':
return !msgObj.effect
Expand Down
8 changes: 4 additions & 4 deletions src/arena/magics/__snapshots__/chainLightning.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`chainLightning should hit 3 targets 1`] = `
exports[`chainLightning should hit 3 targets 2`] = `63`;

exports[`chainLightning should hit 3 targets 3`] = `
"*architecto* сотворил _Цепь молний_ на *aspernatur* нанеся 2.36 урона
"*architecto* сотворил _Цепь молний_ на *aspernatur* нанеся 6.36 урона
\\[ aspernatur ⚡ 💔-2.36/5.63 📖31
architecto ⚡ 💔-2.11/5.89 📖17
quia ⚡ 💔-1.89/6.11 📖15 ]"
Expand All @@ -44,7 +44,7 @@ exports[`chainLightning should hit 3 targets without clan 1`] = `
exports[`chainLightning should hit 3 targets without clan 2`] = `63`;

exports[`chainLightning should hit 3 targets without clan 3`] = `
"*qui* сотворил _Цепь молний_ на *ex* нанеся 2.34 урона
"*qui* сотворил _Цепь молний_ на *ex* нанеся 6.32 урона
\\[ ex ⚡ 💔-2.34/5.66 📖31
qui ⚡ 💔-2.11/5.89 📖17
doloremque ⚡ 💔-1.87/6.13 📖15 ]"
Expand All @@ -69,7 +69,7 @@ exports[`chainLightning should hit 4 targets 1`] = `
exports[`chainLightning should hit 4 targets 2`] = `104`;

exports[`chainLightning should hit 4 targets 3`] = `
"*explicabo* сотворил _Цепь молний_ на *et* нанеся 3.4 урона
"*explicabo* сотворил _Цепь молний_ на *et* нанеся 11.49 урона
\\[ et ⚡ 💔-3.4/4.64 📖39
explicabo ⚡ 💔-3.02/4.98 📖24
eum ⚡ 💔-2.69/5.31 📖22
Expand All @@ -95,7 +95,7 @@ exports[`chainLightning should hit 5 targets 1`] = `
exports[`chainLightning should hit 5 targets 2`] = `153`;

exports[`chainLightning should hit 5 targets 3`] = `
"*asperiores* сотворил _Цепь молний_ на *magni* нанеся 4.38 урона
"*asperiores* сотворил _Цепь молний_ на *magni* нанеся 17.58 урона
\\[ magni ⚡ 💔-4.38/3.59 📖47
asperiores ⚡ 💔-3.94/4.06 📖32
labore ⚡ 💔-3.53/4.47 📖28
Expand Down
4 changes: 2 additions & 2 deletions src/arena/magics/__snapshots__/fireBall.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`fireBall should hit 1 target 1`] = `
exports[`fireBall should hit 1 target 2`] = `120`;

exports[`fireBall should hit 1 target 3`] = `
"*explicabo* сотворил _Огненный шар_ на *aperiam* нанеся 8.75 урона
"*explicabo* сотворил _Огненный шар_ на *aperiam* нанеся 13.59 урона
\\[ aperiam 🔥 💔-8.75/-5.59 📖80
aperiam 🔥 💔-1.21/-1.96 📖10
aperiam 🔥 💔-1.21/-3.17 📖10
Expand All @@ -46,7 +46,7 @@ exports[`fireBall should hit 6 targets 1`] = `
exports[`fireBall should hit 6 targets 2`] = `117`;

exports[`fireBall should hit 6 targets 3`] = `
"*asperiores* сотворил _Огненный шар_ на *magni* нанеся 8.72 урона
"*asperiores* сотворил _Огненный шар_ на *magni* нанеся 13.25 урона
\\[ magni 🔥 💔-8.72/-0.72 📖80
labore 🔥 💔-1.21/6.79 📖10
iure 🔥 💔-0.91/7.09 📖7
Expand Down
2 changes: 1 addition & 1 deletion src/arena/magics/__snapshots__/fireRain.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`fireRain should hit clan targets 1`] = `
exports[`fireRain should hit clan targets 2`] = `234`;

exports[`fireRain should hit clan targets 3`] = `
"*asperiores* сотворил _Огненный дождь_ на *magni* нанеся 4.03 урона
"*asperiores* сотворил _Огненный дождь_ на *magni* нанеся 28.32 урона
\\[ magni 🔥 💔-4.03/2.59 📖40
labore 🔥 💔-5.41/2.59 📖43
iure 🔥 💔-4.07/3.93 📖33
Expand Down

0 comments on commit 9f146e4

Please sign in to comment.