From 249f62759e0fa6e453508b9d3d0b0636a6697be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 28 Apr 2026 22:31:28 -0500 Subject: [PATCH] feat: characteristics Co-authored-by: Copilot --- .../src/core/tankopedia/characteristics.ts | 5 +- .../core/tankopedia/computeCharacteristics.ts | 14 +- .../pages/[...locale]/tanks/[slug]/_index.tsx | 246 ++++++++++++++---- 3 files changed, 204 insertions(+), 61 deletions(-) diff --git a/packages/website-ue/src/core/tankopedia/characteristics.ts b/packages/website-ue/src/core/tankopedia/characteristics.ts index 45a5326bf..090acb17e 100644 --- a/packages/website-ue/src/core/tankopedia/characteristics.ts +++ b/packages/website-ue/src/core/tankopedia/characteristics.ts @@ -20,7 +20,6 @@ type Characteristic = (helpers: { state: TankState; tank: Tank; parameters: StageParameters; - id: string; }) => CharacteristicOutput; export type CharacteristicName = keyof typeof characteristics; @@ -409,8 +408,8 @@ export const characteristics = { return tank.tank!.tank_type; }, - id({ id }) { - return id; + id({ state }) { + return state.id; }, slug({ tank }) { diff --git a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts index 6c3a77f22..0efac3827 100644 --- a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts +++ b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts @@ -3,7 +3,7 @@ import { ShellUpgradeSingleChange_AttributeName, TankAttributeChange_AttributeName, } from "@protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; -import { aggregateStageParameters } from "./aggregateParameters"; +import { aggregateParameters } from "./aggregateParameters"; import { characteristics, type CharacteristicName, @@ -16,15 +16,8 @@ export type ComputedCharacteristics = Record< CharacteristicOutput >; -export function computeCharacteristics( - id: string, - tank: Tank, - state: TankState, -) { - const parameters = aggregateStageParameters( - tank.tank!.base_stats!, - tank.tank!.upgrade_stages.slice(0, state.stage), - ); +export function computeCharacteristics(tank: Tank, state: TankState) { + const parameters = aggregateParameters(tank.tank!, state.upgrades); const computed: Partial = {}; @@ -94,7 +87,6 @@ export function computeCharacteristics( state, tank, parameters, - id, }); computed[name] = value; } diff --git a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx index a83cfbc44..9f336f628 100644 --- a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx @@ -1,12 +1,8 @@ import { Grade } from "@blitzkit/closed/protos/game/proto/legacy/blitz_static_standard_grades_enum"; -import { PenetrationGroup_CommonData } from "@blitzkit/closed/protos/game/proto/legacy/blitz_static_tank_penetration_group"; -import { - PenetrationGroupUpgrade_TankPart, - StageParameters_StageType, - TankAttributeChange_AttributeName, -} from "@blitzkit/closed/protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; +import { StageParameters_StageType } from "@blitzkit/closed/protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; +import { useMemo } from "react"; import { api } from "../../../../core/api/dynamic"; -import { aggregateParameters } from "../../../../core/tankopedia/aggregateParameters"; +import { computeCharacteristics } from "../../../../core/tankopedia/computeCharacteristics"; import { useAwait } from "../../../../hooks/useAwait"; import { useGameStrings } from "../../../../hooks/useGameStrings"; import { LocaleProvider } from "../../../../hooks/useLocale"; @@ -38,9 +34,9 @@ function Content() { `tank-${protagonist.id}`, ); - const parameters = aggregateParameters( - protagonistTank.tank!, - protagonist.upgrades, + const { characteristics } = useMemo( + () => computeCharacteristics(protagonistTank, protagonist), + [protagonist], ); return ( @@ -148,44 +144,200 @@ function Content() { ); })} -

parameters

+

characteristics

-

attributes

- - {parameters.attributes.map((attribute) => { - return ( - - {TankAttributeChange_AttributeName[attribute.attribute_name]}:{" "} - {attribute.value} - - ); - })} - -

penetration groups

- - {parameters.penetration_groups_upgrades.map((upgrade) => { - return ( - <> -

{PenetrationGroupUpgrade_TankPart[upgrade.tank_part]}

- - - primary armor ({upgrade.primary_armor.length}):{" "} - {upgrade.primary_armor} - - -
- - {upgrade.penetration_groups.map((group) => { - return ( - - {group.group_name}: {group.armor} ( - {PenetrationGroup_CommonData[group.common_data]}) - - ); - })} - - ); - })} + {Object.entries(characteristics).map(([key, value]) => ( +

+ {key}: {value} +

+ ))} ); + + // const parameters = aggregateParameters( + // protagonistTank.tank!, + // protagonist.upgrades, + // ); + + // if (parameters.modules_upgrades.length > 0) { + // throw new Error("Modules upgrades display not implemented"); + // } + + // return ( + // <> + //

{protagonist.id}

+ + //
+ + //

upgrades

+ + // {protagonistTank.tank!.upgrade_lines.map((line) => { + // return ( + // <> + //

+ // {line.name} ({protagonist.upgrades[line.name]}) + //

+ + //
+ // {line.stages.map((stage, index) => { + // if (stage.custom_picture) { + // throw new Error("Custom picture not supported"); + // } + + // return ( + // + // ); + // })} + //
+ // + // ); + // })} + + //

characteristics

+ + // {} + + //

parameters

+ + //

attributes

+ + // {parameters.attributes.map((attribute) => { + // return ( + // + // {TankAttributeChange_AttributeName[attribute.attribute_name]}:{" "} + // {attribute.value} + // + // ); + // })} + + //

penetration groups

+ + // {parameters.penetration_groups_upgrades.map((upgrade) => { + // return ( + // <> + //

{PenetrationGroupUpgrade_TankPart[upgrade.tank_part]}

+ + // + // primary armor ({upgrade.primary_armor.length}):{" "} + // {upgrade.primary_armor} + // + + //
+ + // {upgrade.penetration_groups.map((group) => { + // return ( + // + // {group.group_name}: {group.armor} ( + // {PenetrationGroup_CommonData[group.common_data]}) + // + // ); + // })} + // + // ); + // })} + + //

modules ({parameters.modules_upgrades.length})

+ + // {parameters.modules_upgrades.map((upgrade) => { + // return ( + // {ModuleUpgrade_AttributeName[upgrade.attribute_name]} + // ); + // })} + + //

shells

+ + // {parameters.shells_upgrades.map((upgrade) => { + // return ( + // <> + //

+ // {upgrade.shell_id}: {ShellUpgrade_ShellType[upgrade.shell_type]} + //

+ + //
+  //             silver_price: {JSON.stringify(upgrade.silver_price, null, 2)}
+  //           
+ + //
+  //             tray_shells: {JSON.stringify(upgrade.tray_shells, null, 2)}
+  //           
+ // + // ); + // })} + // + // ); }