Display sub name in consumption table

This commit is contained in:
Kalle 2022-09-14 19:04:47 +03:00
parent 60b2038a2f
commit 01b2693e88
2 changed files with 16 additions and 8 deletions

View File

@ -7,7 +7,7 @@ import { Main } from "~/components/Main";
import type { Stat } from "~/modules/analyzer";
import { useAnalyzeBuild } from "~/modules/analyzer";
import type { AnalyzedBuild, FullInkTankOption } from "~/modules/analyzer";
import type { MainWeaponId } from "~/modules/in-game-lists";
import type { MainWeaponId, SubWeaponId } from "~/modules/in-game-lists";
import styles from "~/styles/analyzer.css";
import { Image } from "~/components/Image";
import { specialWeaponImageUrl, subWeaponImageUrl } from "~/utils/urls";
@ -64,7 +64,10 @@ export default function BuildAnalyzerPage() {
title="Actions per ink tank"
containerClassName="analyzer__consumption-table-container"
>
<ConsumptionTable options={analyzed.stats.fullInkTankOptions} />
<ConsumptionTable
options={analyzed.stats.fullInkTankOptions}
subWeaponId={analyzed.weapon.subWeaponSplId}
/>
</StatCategory>
</div>
</div>
@ -148,8 +151,14 @@ function StatCard({
);
}
function ConsumptionTable({ options }: { options: Array<FullInkTankOption> }) {
const { t } = useTranslation("analyzer");
function ConsumptionTable({
options,
subWeaponId,
}: {
options: Array<FullInkTankOption>;
subWeaponId: SubWeaponId;
}) {
const { t } = useTranslation(["analyzer", "weapons"]);
const maxSubsToUse = Math.max(...options.map((opt) => opt.subsUsed));
const types = Array.from(new Set(options.map((opt) => opt.type)));
@ -158,9 +167,9 @@ function ConsumptionTable({ options }: { options: Array<FullInkTankOption> }) {
<table>
<thead>
<tr>
<th>{t("stat.consumption.bomb")}</th>
<th>{t(`weapons:SUB_${subWeaponId}`)}</th>
{types.map((type) => (
<th key={type}>{t(`stat.consumption.${type}`)}</th>
<th key={type}>{t(`analyzer:stat.consumption.${type}`)}</th>
))}
</tr>
</thead>
@ -180,7 +189,7 @@ function ConsumptionTable({ options }: { options: Array<FullInkTankOption> }) {
</tbody>
</table>
<div className="analyzer__consumption-table-explanation">
{t("consumptionExplanation", { maxSubsToUse })}
{t("analyzer:consumptionExplanation", { maxSubsToUse })}
</div>
</>
);

View File

@ -1,7 +1,6 @@
{
"stat.specialPoints": "Points to special",
"stat.specialLost": "Special lost when splatted",
"stat.consumption.bomb": "Bombs",
"stat.consumption.NORMAL": "Shots",
"stat.consumption.SWING": "Swings",
"stat.consumption.VERTICAL_SWING": "Vertical swings",