Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #193 from RaenonX-DL/dev
Browse files Browse the repository at this point in the history
v2.9.3 Release
  • Loading branch information
RaenonX authored Jul 7, 2021
2 parents 4cf75cb + 2359404 commit 605a9e6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ describe('Sort ATK skill entries', () => {
expect(entries[3]).toBeGreaterThan(entries[4]);
});

it('sorts entries by total mods if not displaying actual damage', async () => {
const inputData: InputData = {
...inputDataTemplate,
sortBy: 'damage',
};

const entries = calculateEntries(data, inputData, elemBonusData)
.map((entry) => entry.skillDamage.totalMods)
.filter((x, i, a) => !i || x !== a[i - 1]);
expect(entries[0]).toBeGreaterThan(entries[1]);
expect(entries[1]).toBeGreaterThan(entries[2]);
expect(entries[2]).toBeGreaterThan(entries[3]);
expect(entries[3]).toBeGreaterThan(entries[4]);
});

it('sorts entries by SP', async () => {
const inputData: InputData = {
...inputDataTemplate,
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/gameData/skillAtk/sorter/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const isSkillNotCommonSp = (entry: CalculatedSkillEntry) => entry.skillEntry.ski
type SortFuncLookup = { [sortBy in SortBy]: (entryA: CalculatedSkillEntry, entryB: CalculatedSkillEntry) => number }

export const sortFunc: SortFuncLookup = {
damage: sortDescending({getComparer: (element) => element.skillDamage.expected}),
damage: sortDescending({getComparer: (element) => element.skillDamage.totalMods}),
sp: sortAscending({
getComparer: (element) => element.skillEntry.skill.spMax,
isToPutLast: isSkillNotCommonSp,
Expand Down
51 changes: 51 additions & 0 deletions src/utils/game/damage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,55 @@ describe('Damage calculation', () => {
expect(Math.round(damage.highest)).toStrictEqual(36671575);
expect(damage.totalMods).toStrictEqual(45.45);
});

it('does not calculate actual damage if not to display', () => {
const inputData: InputData = generateInputData({display: {actualDamage: false}});

const attackingSkillData = {
...attackingSkillDataTemplate,
skill: {
...attackingSkillDataTemplate.skill,
modsMax: [40, 5.45],
crisisMax: [1, 1],
buffCountBoost: [{inEffect: 0, each: 0, limit: 0}, {inEffect: 0, each: 0, limit: 0}],
},
};

const damage: CalculateDamageReturn = calculateDamage(inputData, attackingSkillData, 1.5);

expect(Math.round(damage.lowest)).toStrictEqual(0);
expect(Math.round(damage.expected)).toStrictEqual(0);
expect(Math.round(damage.highest)).toStrictEqual(0);
expect(damage.totalMods).toStrictEqual(45.45);
});

it('calculates total mods with buff boost even if actual damage is not calculated', () => {
const inputData: InputData = generateInputData({
params: {
buff: {
count: 45,
},
},
display: {
actualDamage: false,
},
});

const attackingSkillData = {
...attackingSkillDataTemplate,
skill: {
...attackingSkillDataTemplate.skill,
modsMax: [40, 5.45],
crisisMax: [1, 1],
buffCountBoost: [{inEffect: 0, each: 0.05, limit: 0}, {inEffect: 0, each: 0.05, limit: 0}],
},
};

const damage: CalculateDamageReturn = calculateDamage(inputData, attackingSkillData, 1.5);

expect(Math.round(damage.lowest)).toStrictEqual(0);
expect(Math.round(damage.expected)).toStrictEqual(0);
expect(Math.round(damage.highest)).toStrictEqual(0);
expect(damage.totalMods).toStrictEqual(147.7125);
});
});

0 comments on commit 605a9e6

Please sign in to comment.