diff --git a/packages/website-ue/src/core/tankopedia/characteristics.ts b/packages/website-ue/src/core/tankopedia/characteristics.ts index b04c9f27f..37ce5e4ed 100644 --- a/packages/website-ue/src/core/tankopedia/characteristics.ts +++ b/packages/website-ue/src/core/tankopedia/characteristics.ts @@ -6,9 +6,18 @@ import { export type CharacteristicOutput = number | null; type Characteristic = (helpers: { - characteristic: (name: CharacteristicName) => CharacteristicOutput; - attribute: (name: TankAttributeChange_AttributeName) => number; - shell: (name: ShellUpgrageSingleChange_AttributeName) => number; + characteristic: ( + name: CharacteristicName, + error?: boolean + ) => CharacteristicOutput; + attribute: ( + name: TankAttributeChange_AttributeName, + error?: boolean + ) => number; + shell: ( + name: ShellUpgrageSingleChange_AttributeName, + error?: boolean + ) => number; }) => CharacteristicOutput; export type CharacteristicName = keyof typeof characteristics; @@ -82,4 +91,36 @@ export const characteristics = { return 60 * dps; }, + + caliber({ shell }) { + return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_CALIBER); + }, + + normalization({ shell }) { + return shell( + ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_NORMALIZATION + ); + }, + + ricochet({ shell }) { + return shell( + ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_RICOCHET_ANGLE + ); + }, + + shell_velocity({ shell }) { + return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_SPEED); + }, + + shell_range({ shell }) { + return shell( + ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_DISTANCE + ); + }, + + shell_capacity({ shell }) { + return shell( + ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_COUNT + ); + }, } satisfies Record; diff --git a/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts b/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts index c0abe6a66..2581387e7 100644 --- a/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts +++ b/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts @@ -7,10 +7,15 @@ export enum BetterDirection { type CharacteristicsOrder = { group: string; - order: { - name: CharacteristicName; - decimals?: number; - }[]; + order: ( + | { + name: CharacteristicName; + decimals?: number; + } + | { + toy: string; + } + )[]; }[]; export const characteristicsGroups = [ @@ -22,6 +27,19 @@ export const characteristicsGroups = [ { name: "damage" }, { name: "module_damage" }, { name: "penetration" }, + { name: "reload" }, + + { toy: "reload" }, + + { name: "caliber" }, + { name: "normalization" }, + { name: "ricochet" }, + + { toy: "ricochet" }, + + { name: "shell_velocity" }, + { name: "shell_range" }, + { name: "shell_capacity" }, ], }, { diff --git a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts index 0ff19d4e1..cc7d59713 100644 --- a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts +++ b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts @@ -1,7 +1,7 @@ -import type { +import { ShellUpgrageSingleChange_AttributeName, - StageParameters, TankAttributeChange_AttributeName, + type StageParameters, } from "@protos/blitz_static_tank_upgrade_single_stage"; import { characteristics, @@ -27,8 +27,11 @@ export function computeCharacteristics( (attribute) => attribute.attribute_name === name ); - if (!attribute) throw new Error(`Attribute ${name} not found`); - (""); + if (!attribute) { + throw new Error( + `Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found` + ); + } return attribute.value; } @@ -38,13 +41,21 @@ export function computeCharacteristics( (shell) => shell.shell_id === state.shell ); - if (!shell) throw new Error(`Shell ${name} not found`); + if (!shell) { + throw new Error( + `Shell ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found` + ); + } const attribute = shell.changes.find( (change) => change.attribute_name === name ); - if (!attribute) throw new Error(`Shell attribute ${name} not found`); + if (!attribute) { + throw new Error( + `Shell attribute ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found` + ); + } return attribute.value; } diff --git a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx index ba5288c56..2ca6d1290 100644 --- a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx @@ -54,22 +54,26 @@ function Content({ id }: { id: string }) { <>

{group}

- {order.map(({ name, decimals }) => { - const characteristic = characteristics[name]; + {order.map((entry) => { + if ("toy" in entry) { + } else { + const characteristic = characteristics[entry.name]; - if (characteristic === null) return null; + if (characteristic === null) return null; - let rendered: string | number = characteristic; + let rendered: string | number = characteristic; - if (typeof rendered === "number") { - if (decimals !== undefined) rendered = rendered.toFixed(decimals); + if (typeof rendered === "number") { + if (entry.decimals !== undefined) + rendered = rendered.toFixed(entry.decimals); + } + + return ( +

+ {entry.name}: {rendered} +

+ ); } - - return ( -

- {name}: {rendered} -

- ); })} ))}