From be4af0bf84d1097b7f8c805f2af095948403934a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 18 Dec 2025 21:29:10 -0600 Subject: [PATCH] feat: implement some --- .../tankopedia/aggregateStageParameters.ts | 2 - .../src/core/tankopedia/characteristics.ts | 183 ++++++++++++++++++ .../core/tankopedia/characteristicsGroups.ts | 58 +++++- .../core/tankopedia/computeCharacteristics.ts | 13 +- .../src/pages/tanks/[slug]/_index.tsx | 14 +- 5 files changed, 254 insertions(+), 16 deletions(-) diff --git a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts index 984e1bdf3..3b37d7b41 100644 --- a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts +++ b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts @@ -206,8 +206,6 @@ export function aggregateStageParameters( stage0.stage_number = 0; - console.log(stages.length); - stages.forEach((stage) => patch(stage0, stage)); return stage0; diff --git a/packages/website-ue/src/core/tankopedia/characteristics.ts b/packages/website-ue/src/core/tankopedia/characteristics.ts index 05e16750c..d1ca733f8 100644 --- a/packages/website-ue/src/core/tankopedia/characteristics.ts +++ b/packages/website-ue/src/core/tankopedia/characteristics.ts @@ -8,6 +8,7 @@ export type CharacteristicOutput = number | null; type Characteristic = (helpers: { characteristic: (name: CharacteristicName) => CharacteristicOutput; attribute: (name: TankAttributeChange_AttributeName) => number; + attributeSafe: (name: TankAttributeChange_AttributeName) => number | null; shell: (name: ShellUpgrageSingleChange_AttributeName) => number; shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null; }) => CharacteristicOutput; @@ -123,4 +124,186 @@ export const characteristics = { TankAttributeChange_AttributeName.ATTRIBUTE_NAME_AIMING_TIME ); }, + + dispersion_still({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_ANGLE + ); + }, + + dispersion_moving({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_MOVEMENT + ); + }, + + dispersion_hull_traversing({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_VEHICLE_ROTATION + ); + }, + + dispersion_turret_traversing({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_TURRET_ROTATION + ); + }, + + dispersion_shooting({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_AFTER_SHOT + ); + }, + + dispersion_gun_damaged({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_DISPERSION_FACTOR_WHILE_GUN_DAMAGED + ); + }, + + gun_depression({ attributeSafe }) { + return ( + attributeSafe( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_DOWN + ) ?? -Infinity + ); + }, + + gun_elevation({ attributeSafe }) { + return ( + attributeSafe( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_UP + ) ?? -Infinity + ); + }, + + speed_forward({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FORWARD_MAX_SPEED + ); + }, + + speed_backward({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_BACKWARD_MAX_SPEED + ); + }, + + engine_power({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_ENGINE_POWER + ); + }, + + weight({ attribute }) { + return attribute(TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MASS); + }, + + terrain_coefficient_hard({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_HARD + ); + }, + + terrain_coefficient_medium({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_MEDIUM + ); + }, + + terrain_coefficient_soft({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TERRAIN_RESISTANCE_SOFT + ); + }, + + power_to_weight_hard() { + return -1; + }, + + power_to_weight_medium() { + return -1; + }, + + power_to_weight_soft() { + return -1; + }, + + turret_traverse_speed({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_TURRET_ROTATION_SPEED + ); + }, + + hull_traverse_speed_hard() { + return -1; + }, + + hull_traverse_speed_medium() { + return -1; + }, + + hull_traverse_speed_soft() { + return -1; + }, + + health({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_MAX_HEALTH + ); + }, + + fire_chance({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_FIRE_START_CHANCE + ); + }, + + view_range({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CIRCULAR_VISION_RADIUS + ); + }, + + camouflage_still({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_STILL + ); + }, + + camouflage_moving({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_MOVING + ); + }, + + camouflage_shooting_still({ attribute }) { + return attribute( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FACTOR_AT_SHOT + ); + }, + + camouflage_shooting_moving() { + return -1; + }, + + camouflage_on_fire({ attributeSafe }) { + return ( + attributeSafe( + TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FIRE_PENALTY + ) ?? -Infinity + ); + }, + + height() { + return -1; + }, + + length() { + return -1; + }, + + volume() { + return -1; + }, } satisfies Record; diff --git a/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts b/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts index 3d2a8489a..4e0e164e9 100644 --- a/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts +++ b/packages/website-ue/src/core/tankopedia/characteristicsGroups.ts @@ -18,7 +18,7 @@ type CharacteristicsOrder = { )[]; }[]; -export const characteristicsGroups = [ +export const characteristicsGroups: CharacteristicsOrder = [ { group: "firepower", order: [ @@ -40,19 +40,69 @@ export const characteristicsGroups = [ { name: "shell_velocity" }, { name: "shell_range" }, { name: "shell_capacity" }, + { name: "aim_time" }, + + { name: "dispersion_still" }, + { name: "dispersion_moving" }, + { name: "dispersion_hull_traversing" }, + { name: "dispersion_turret_traversing" }, + { name: "dispersion_shooting" }, + { name: "dispersion_gun_damaged" }, + + { name: "gun_depression" }, + { name: "gun_elevation" }, + + { toy: "flexibility" }, ], }, { group: "maneuverability", - order: [], + order: [ + { name: "speed_forward" }, + { name: "speed_backward" }, + + { name: "engine_power" }, + { name: "weight" }, + + { name: "terrain_coefficient_hard" }, + { name: "terrain_coefficient_medium" }, + { name: "terrain_coefficient_soft" }, + + { name: "power_to_weight_hard" }, + { name: "power_to_weight_medium" }, + { name: "power_to_weight_soft" }, + + { name: "turret_traverse_speed" }, + { name: "hull_traverse_speed_hard" }, + { name: "hull_traverse_speed_medium" }, + { name: "hull_traverse_speed_soft" }, + + { toy: "traverse" }, + ], }, { group: "survivability", - order: [], + order: [ + { name: "health" }, + { name: "fire_chance" }, + { name: "view_range" }, + + { toy: "view_range" }, + + { name: "camouflage_still" }, + { name: "camouflage_moving" }, + { name: "camouflage_shooting_still" }, + { name: "camouflage_shooting_moving" }, + { name: "camouflage_on_fire" }, + + { name: "height" }, + { name: "length" }, + { name: "volume" }, + ], }, { group: "miscellaneous", order: [], }, -] satisfies CharacteristicsOrder; +]; diff --git a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts index 4d60b3328..d0aa852db 100644 --- a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts +++ b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts @@ -22,18 +22,24 @@ export function computeCharacteristics( throw new Error(`${name} not computed yet`); } - function attribute(name: TankAttributeChange_AttributeName) { + function attributeSafe(name: TankAttributeChange_AttributeName) { const attribute = parameters.attributes.find( (attribute) => attribute.attribute_name === name ); - if (!attribute) { + return attribute ? attribute.value : null; + } + + function attribute(name: TankAttributeChange_AttributeName) { + const attribute = attributeSafe(name); + + if (attribute === null) { throw new Error( `Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found` ); } - return attribute.value; + return attribute; } function shellSafe(name: ShellUpgrageSingleChange_AttributeName) { @@ -71,6 +77,7 @@ export function computeCharacteristics( const value = characteristics[name]({ characteristic, attribute, + attributeSafe, shell, shellSafe, }); diff --git a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx index b258ca024..b71b25867 100644 --- a/packages/website-ue/src/pages/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/tanks/[slug]/_index.tsx @@ -81,16 +81,16 @@ function Content({ id }: { id: string }) { if (characteristic === null) return null; - let rendered: string | number = characteristic; + let rendered: string | number; - if (typeof rendered === "number") { - if (rendered === Infinity) { - rendered = "∞"; + if (Number.isFinite(characteristic)) { + if (entry.decimals === undefined) { + rendered = characteristic; } else { - if (entry.decimals !== undefined) { - rendered = rendered.toFixed(entry.decimals); - } + rendered = characteristic.toFixed(entry.decimals); } + } else { + rendered = `${Math.sign(characteristic) === 1 ? "" : "-"}∞`; } return (