From 3da154b75d4b5ab1b9c0f91918f47a31259f74ee Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sat, 9 Nov 2024 19:16:06 -0600 Subject: [PATCH] feat: shell capacity --- .../core/src/protos/tank_definitions.proto | 1 + packages/core/src/protos/tank_definitions.ts | 18 ++++++++++++++++++ .../scripts/src/buildAssets/definitions.ts | 2 ++ .../website/src/components/Compare/Body.tsx | 6 ++++++ .../components/TankSearch/components/Sort.tsx | 8 ++++++++ .../src/components/TankSearch/index.tsx | 10 ++++++++++ .../components/Characteristics/index.tsx | 4 +++- .../src/core/blitzkit/tankCharacteristics.ts | 2 ++ .../stores/tankopediaPersistent/constants.ts | 2 ++ 9 files changed, 52 insertions(+), 1 deletion(-) diff --git a/packages/core/src/protos/tank_definitions.proto b/packages/core/src/protos/tank_definitions.proto index e8d5b5d17..533495f57 100644 --- a/packages/core/src/protos/tank_definitions.proto +++ b/packages/core/src/protos/tank_definitions.proto @@ -155,6 +155,7 @@ message GunDefinitionBase { required float dispersion_shot = 12; required float dispersion_damaged = 13; repeated Unlock unlocks = 14; + required uint32 shell_capacity = 15; } message ShellDefinition { diff --git a/packages/core/src/protos/tank_definitions.ts b/packages/core/src/protos/tank_definitions.ts index 00e4d8bde..735f95a56 100644 --- a/packages/core/src/protos/tank_definitions.ts +++ b/packages/core/src/protos/tank_definitions.ts @@ -484,6 +484,7 @@ export interface GunDefinitionBase { dispersion_shot: number; dispersion_damaged: number; unlocks: Unlock[]; + shell_capacity: number; } export interface ShellDefinition { @@ -2944,6 +2945,7 @@ function createBaseGunDefinitionBase(): GunDefinitionBase { dispersion_shot: 0, dispersion_damaged: 0, unlocks: [], + shell_capacity: 0, }; } @@ -2991,6 +2993,9 @@ export const GunDefinitionBase: MessageFns = { for (const v of message.unlocks) { Unlock.encode(v!, writer.uint32(114).fork()).join(); } + if (message.shell_capacity !== 0) { + writer.uint32(120).uint32(message.shell_capacity); + } return writer; }, @@ -3113,6 +3118,14 @@ export const GunDefinitionBase: MessageFns = { message.unlocks.push(Unlock.decode(reader, reader.uint32())); continue; } + case 15: { + if (tag !== 120) { + break; + } + + message.shell_capacity = reader.uint32(); + continue; + } } if ((tag & 7) === 4 || tag === 0) { break; @@ -3144,6 +3157,7 @@ export const GunDefinitionBase: MessageFns = { assertSet("GunDefinitionBase.dispersion_damaged", object.dispersion_damaged), ), unlocks: globalThis.Array.isArray(object?.unlocks) ? object.unlocks.map((e: any) => Unlock.fromJSON(e)) : [], + shell_capacity: globalThis.Number(assertSet("GunDefinitionBase.shell_capacity", object.shell_capacity)), }; }, @@ -3191,6 +3205,9 @@ export const GunDefinitionBase: MessageFns = { if (message.unlocks?.length) { obj.unlocks = message.unlocks.map((e) => Unlock.toJSON(e)); } + if (message.shell_capacity !== 0) { + obj.shell_capacity = Math.round(message.shell_capacity); + } return obj; }, @@ -3215,6 +3232,7 @@ export const GunDefinitionBase: MessageFns = { message.dispersion_shot = object.dispersion_shot ?? 0; message.dispersion_damaged = object.dispersion_damaged ?? 0; message.unlocks = object.unlocks?.map((e) => Unlock.fromPartial(e)) || []; + message.shell_capacity = object.shell_capacity ?? 0; return message; }, }; diff --git a/packages/scripts/src/buildAssets/definitions.ts b/packages/scripts/src/buildAssets/definitions.ts index f7cc295fb..cf9dea5fc 100644 --- a/packages/scripts/src/buildAssets/definitions.ts +++ b/packages/scripts/src/buildAssets/definitions.ts @@ -311,6 +311,7 @@ interface GunDefinitionsList { afterShot: number; whileGunDamaged: number; }; + maxAmmo: number; aimingTime: number; shotDispersionRadius: number; userString: string; @@ -1174,6 +1175,7 @@ export async function definitions() { dispersion_shot: shotDispersionFactors.afterShot, dispersion_traverse: shotDispersionFactors.turretRotation, unlocks: resolveUnlocks(gun.unlocks), + shell_capacity: gun.maxAmmo ?? gunListEntry.maxAmmo, } satisfies GunDefinitionBase; tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({ diff --git a/packages/website/src/components/Compare/Body.tsx b/packages/website/src/components/Compare/Body.tsx index b2bfa81c1..723c937c4 100644 --- a/packages/website/src/components/Compare/Body.tsx +++ b/packages/website/src/components/Compare/Body.tsx @@ -157,6 +157,12 @@ export function Body({ stats }: BodyProps) { value="shellRange" decimals={0} /> + Shell range + { + $tankopediaSort.setKey('by', 'fire.shellCapacity'); + }} + > + Shell capacity + { diff --git a/packages/website/src/components/TankSearch/index.tsx b/packages/website/src/components/TankSearch/index.tsx index 5205079d1..2540f1c19 100644 --- a/packages/website/src/components/TankSearch/index.tsx +++ b/packages/website/src/components/TankSearch/index.tsx @@ -275,6 +275,16 @@ export const TankSearch = memo( ); break; + case 'fire.shellCapacity': + sorted = filtered.sort( + (a, b) => + a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base + .shell_capacity - + b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base + .shell_capacity, + ); + break; + case 'fire.aimTime': sorted = filtered.sort( (a, b) => diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx index d536bb862..8cfea9bea 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx @@ -329,10 +329,12 @@ export function Characteristics() { {stats.shellVelocity} - {stats.shellRange} + + {stats.shellCapacity} + = { 'fire.reload': 's', 'fire.shellVelocity': 'm/s', 'fire.shellRange': 'm', + 'fire.shellCapacity': undefined, 'fire.standardPenetration': 'mm', 'maneuverability.backwardsSpeed': 'kph', 'maneuverability.forwardsSpeed': 'kph', @@ -48,6 +49,7 @@ export const SORT_NAMES = { 'fire.damage': 'damage', 'fire.shellVelocity': 'shell velocity', 'fire.shellRange': 'shell range', + 'fire.shellCapacity': 'shell capacity', 'fire.aimTime': 'aim time', 'fire.dispersionStill': 'dispersion still', 'fire.dispersionMoving': 'dispersion moving',