From ed4b72d85c15b9bd5dfef5e49dd957781b2c6493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 30 Nov 2025 22:26:13 -0600 Subject: [PATCH] feat: upgrade stages --- .../src/constants/characteristicsOrder.ts | 18 ++++++ .../src/pages/tanks/[slug]/_index.tsx | 55 ++++++++++++++++--- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/packages/website-ue/src/constants/characteristicsOrder.ts b/packages/website-ue/src/constants/characteristicsOrder.ts index 6a347bd0b..9348e88b3 100644 --- a/packages/website-ue/src/constants/characteristicsOrder.ts +++ b/packages/website-ue/src/constants/characteristicsOrder.ts @@ -248,3 +248,21 @@ export const characteristicsOrder: CharacteristicsOrder = [ ], }, ]; + +if (import.meta.env.DEV) { + for (const name of Object.values(TankAttributeChange_AttributeName).filter( + (value) => typeof value === "number" + )) { + if (name === TankAttributeChange_AttributeName.ATTRIBUTE_NAME_UNSPECIFIED) { + continue; + } + + const isImplemented = characteristicsOrder.some((group) => + group.attributes.some((attribute) => attribute.name === name) + ); + + if (!isImplemented) { + throw new Error(`Attribute ${name} is not implemented`); + } + } +} diff --git a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx index b2a232fab..dd57078cc 100644 --- a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx @@ -1,7 +1,9 @@ import { + TankAttributeChange, TankAttributeChange_AttributeName, TankAttributeChange_Modifier, } from "@protos/blitz_static_tank_upgrade_single_stage"; +import { times } from "lodash-es"; import { Suspense, useMemo } from "react"; import { CharacteristicsGroup, @@ -29,17 +31,40 @@ function Content({ id }: { id: string }) { Record > = {}; - for (const { attribute_name, value, modifier } of tank.base_stats! - .attributes) { - if (modifier !== TankAttributeChange_Modifier.MODIFIER_OVERRIDE) { - throw new Error( - `Unexpected modifier ${TankAttributeChange_Modifier[modifier]}` - ); - } + function patch(changes: TankAttributeChange[]) { + for (const { attribute_name, value, modifier } of changes) { + switch (modifier) { + case TankAttributeChange_Modifier.MODIFIER_OVERRIDE: + attributes[attribute_name] = value; + break; - attributes[attribute_name] = value; + case TankAttributeChange_Modifier.MODIFIER_MULTIPLY: { + if (!(attribute_name in attributes)) { + throw new Error( + `Missing attribute ${TankAttributeChange_AttributeName[attribute_name]} to modify` + ); + } + } + + case TankAttributeChange_Modifier.MODIFIER_MULTIPLY: { + attributes[attribute_name]! *= value; + break; + } + + default: + throw new Error( + `Unhandled modified ${TankAttributeChange_Modifier[modifier]}` + ); + } + } } + patch(tank.base_stats!.attributes); + + times(stage, (index) => { + patch(tank.upgrade_stages[index].attributes); + }); + return attributes; }, [stage]); @@ -49,6 +74,20 @@ function Content({ id }: { id: string }) {

Characteristics

+
+ {times(tank.upgrade_stages.length, (index) => ( + + ))} +
+ {characteristicsOrder.map((group) => ( <>

{CharacteristicsGroup[group.group]}