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

Commit

Permalink
ADD - Show info about gradual fill skills (#175)
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Jul 7, 2021
1 parent ed037e2 commit 58c5579
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,25 @@ export const SpEfficiencyTable = ({calculatedData, statusEnums}: SectionSpInfoPr
<td>{calculatedData.efficiency.modPctPer1KSsp.toFixed(2)}%</td>
</tr>
}
{
calculatedData.skillEntry.skill.spGradualPctMax > 0 &&
<tr>
<td>{t((t) => t.game.skillAtk.spInfo.spPctPerSec)}</td>
<td>{calculatedData.skillEntry.skill.spGradualPctMax.toFixed(2)}%</td>
</tr>
}
{
!!calculatedData.skillEntry.skill.afflictions.length &&
<>
<tr>
<td>{t((t) => t.game.skillAtk.spInfo.efficiency.secPer1KSp)}</td>
<td>
<AfflictionDataCell statusEnums={statusEnums} data={calculatedData.efficiency.secPer1KSp}/>
</td>
</tr>
{
!calculatedData.skillEntry.skill.spGradualPctMax &&
<tr>
<td>{t((t) => t.game.skillAtk.spInfo.efficiency.secPer1KSp)}</td>
<td>
<AfflictionDataCell statusEnums={statusEnums} data={calculatedData.efficiency.secPer1KSp}/>
</td>
</tr>
}
{
calculatedData.skillEntry.skill.sharable &&
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {SectionSpInfoProps} from './main';
export const SpInfoTable = ({calculatedData}: Pick<SectionSpInfoProps, 'calculatedData'>) => {
const {t} = useI18n();

const sp = calculatedData.skillEntry.skill.spMax.toFixed(0);

return (
<div className="mt-2">
<table>
Expand All @@ -18,7 +20,14 @@ export const SpInfoTable = ({calculatedData}: Pick<SectionSpInfoProps, 'calculat
<td className={styles.ssCost}>{t((t) => t.game.skillAtk.spInfo.ssCost)}</td>
</tr>
<tr>
<td className={styles.sp}>{calculatedData.skillEntry.skill.spMax.toFixed(0)}</td>
<td className={styles.sp}>{
calculatedData.skillEntry.skill.spGradualPctMax ?
t(
(t) => t.game.skillAtk.spInfo.spGradualFill,
{secs: calculatedData.efficiency.spFullFillSec.toFixed(1), sp},
) :
sp
}</td>
<td className={styles.ssp}>{
calculatedData.skillEntry.skill.sharable ?
calculatedData.skillEntry.skill.ssSp.toFixed(0) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,115 @@ describe('SP info section', () => {
expect(screen.getByText(translationEN.game.skillAtk.spInfo.efficiency.secPer1KSp)).toBeInTheDocument();
expect(screen.getByText(translationEN.game.skillAtk.spInfo.efficiency.secPer1KSsp)).toBeInTheDocument();
});

it('hides affliction efficiency if the skill gradually fills', async () => {
const calculatedData: CalculatedSkillEntry = {
...calculatedDataTemplate,
skillEntry: {
...calculatedDataTemplate.skillEntry,
skill: {
...calculatedDataTemplate.skillEntry.skill,
spGradualPctMax: 2.5,
},
},
efficiency: {
...calculatedDataTemplate.efficiency,
spFullFillSec: 40,
},
};

renderReact(() => (
<SectionSpInfo
calculatedData={calculatedData}
statusEnums={statusEnums}
/>
));

const efficiencyButton = screen.getByText(
translationEN.game.skillAtk.spInfo.efficiencyIndexes,
{selector: 'button'},
);
userEvent.click(efficiencyButton);

await waitFor(() => expect(screen.getByText(
translationEN.game.skillAtk.spInfo.efficiency.modPctPer1KSp,
{selector: '.collapse.show *'},
)).toBeInTheDocument());
expect(screen.queryByText(translationEN.game.skillAtk.spInfo.efficiency.secPer1KSp)).not.toBeInTheDocument();
});

it('shows SP % per second if the skill gradually fills', async () => {
const calculatedData: CalculatedSkillEntry = {
...calculatedDataTemplate,
skillEntry: {
...calculatedDataTemplate.skillEntry,
skill: {
...calculatedDataTemplate.skillEntry.skill,
spMax: 8000,
spGradualPctMax: 2.5,
},
},
efficiency: {
...calculatedDataTemplate.efficiency,
spFullFillSec: 40,
},
};

renderReact(() => (
<SectionSpInfo
calculatedData={calculatedData}
statusEnums={statusEnums}
/>
));
expect(screen.getByText('40.0 secs (8000)')).toBeInTheDocument();

const efficiencyButton = screen.getByText(
translationEN.game.skillAtk.spInfo.efficiencyIndexes,
{selector: 'button'},
);
userEvent.click(efficiencyButton);

await waitFor(() => expect(screen.getByText(
translationEN.game.skillAtk.spInfo.efficiency.modPctPer1KSp,
{selector: '.collapse.show *'},
)).toBeInTheDocument());
expect(screen.getByText(translationEN.game.skillAtk.spInfo.spPctPerSec)).toBeInTheDocument();
expect(screen.getByText('2.50%')).toBeInTheDocument();
});

it('does not show SP % per second if the skill is SP-based', async () => {
const calculatedData: CalculatedSkillEntry = {
...calculatedDataTemplate,
skillEntry: {
...calculatedDataTemplate.skillEntry,
skill: {
...calculatedDataTemplate.skillEntry.skill,
spMax: 8000,
},
},
efficiency: {
...calculatedDataTemplate.efficiency,
spFullFillSec: 0,
},
};

renderReact(() => (
<SectionSpInfo
calculatedData={calculatedData}
statusEnums={statusEnums}
/>
));

const efficiencyButton = screen.getByText(
translationEN.game.skillAtk.spInfo.efficiencyIndexes,
{selector: 'button'},
);
userEvent.click(efficiencyButton);

await waitFor(() => expect(screen.getByText(
translationEN.game.skillAtk.spInfo.efficiency.modPctPer1KSp,
{selector: '.collapse.show *'},
)).toBeInTheDocument());
expect(screen.queryByText(translationEN.game.skillAtk.spInfo.spPctPerSec)).not.toBeInTheDocument();
});
});
2 changes: 2 additions & 0 deletions src/i18n/translations/cht/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ export const translation: TranslationStruct = {
secPer1KSsp: '異常效期 (秒) / 1K SSP',
},
sp: 'SP',
spGradualFill: '{{secs}} 秒 ({{sp}})',
spPctPerSec: '每秒回復 SP %',
ssp: 'SSP',
ssCost: 'SS Cost',
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/translations/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ export type TranslationStruct = {
},
spInfo: {
efficiencyIndexes: string,
efficiency: {[index in keyof Efficiency]: string},
efficiency: {[index in keyof Omit<Efficiency, 'spFullFillSec'>]: string},
sp: string,
spGradualFill: string,
spPctPerSec: string,
ssp: string,
ssCost: string,
},
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/translations/en/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ export const translation: TranslationStruct = {
secPer1KSsp: 'Affliction (sec) / 1K SSP',
},
sp: 'SP',
spGradualFill: '{{secs}} secs ({{sp}})',
spPctPerSec: 'SP Regen % / sec',
ssp: 'SSP',
ssCost: 'SS Cost',
},
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/translations/jp/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export const translation: TranslationStruct = {
secPer1KSsp: '異常效期 (秒) / 1K SSP',
},
sp: 'SP',
spGradualFill: '{{secs}} secs ({{sp}})',
spPctPerSec: 'SP Regen % / sec',
ssp: 'SSP',
ssCost: 'SS Cost',
},
Expand Down

0 comments on commit 58c5579

Please sign in to comment.