TankopediaCharacteristics

This commit is contained in:
tresabhi committed 2026-09-30 18:22:18 -05:00
1 parent 5cae5d1583
commit 74fbd15c5f
9 files changed
+521 -68

No files matched your search

@@ -1,7 +1,10 @@
import { useMemo } from "react";
import { api } from "../../../../../api/dynamic";
import type { ThicknessRange } from "../../../../../components/StaticArmor";
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
import { defaultEqualizer } from "../../../../../config/equalizer";
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
import { withLocale } from "../../../../../hocs/withLocale";
import { useAwait } from "../../../../../hooks/useAwait";
@@ -13,6 +16,8 @@ interface PageProps {
id: number;
}
const tanks = await api.tanks();
export const Page = withErrorWrapper(
withLocale<PageProps>(({ id }) => {
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
@@ -27,6 +32,27 @@ export const Page = withErrorWrapper(
[protagonist],
);
const equalize = Tankopedia.use((state) => state.equalize);
const thicknessRange = useMemo(() => {
const entries = Object.values(tanks.tanks);
const filtered = entries.filter(
(thisTank) => thisTank.tier === protagonistTank.tier,
);
const value =
(filtered.reduce((accumulator, thisTank) => {
return (
accumulator +
thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near *
((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer)
.penetration
);
}, 0) /
filtered.length) *
(3 / 4);
return { value } satisfies ThicknessRange;
}, [protagonist, equalize]);
return (
<div className={styles.page}>
<div className={styles.loadout}>
@@ -34,8 +60,10 @@ export const Page = withErrorWrapper(
</div>
<div className={styles.sandbox}>
<TankopediaSandbox parameters={parameters} />
<TankopediaCharacteristics characteristics={characteristics} />
<TankopediaSandbox thicknessRange={thicknessRange} />
<TankopediaCharacteristics
computedCharacteristics={characteristics}
/>
</div>
</div>
);