From 32ee10445dee0987f4d3ccaf321adb23bdb06d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:36:11 -0600 Subject: [PATCH] feat: penetration --- scripts/buildAssets/definitions.ts | 22 +++++++++++++++------- src/core/blitzkrieg/tankDefinitions.ts | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/buildAssets/definitions.ts b/scripts/buildAssets/definitions.ts index ec898bd47..cd7a630b6 100644 --- a/scripts/buildAssets/definitions.ts +++ b/scripts/buildAssets/definitions.ts @@ -315,9 +315,9 @@ export async function buildDefinitions() { Object.keys(turret.guns).forEach((gunKey, gunIndex) => { const turretGunEntry = turret.guns[gunKey]; const gunId = toUniqueId(nation, gunList.root.ids[gunKey]); - const gun = gunList.root.shared[gunKey]; + const gunListEntry = gunList.root.shared[gunKey]; const pitchLimitsRaw = - turretGunEntry.pitchLimits ?? gun.pitchLimits; + turretGunEntry.pitchLimits ?? gunListEntry.pitchLimits; const gunPitch = ( typeof pitchLimitsRaw === 'string' ? pitchLimitsRaw @@ -329,7 +329,7 @@ export async function buildDefinitions() { parse(turretGunEntry.models.undamaged).name.split('_')[1], ); const gunName = - strings[gun.userString] ?? gunKey.replaceAll('_', ' '); + strings[gunListEntry.userString] ?? gunKey.replaceAll('_', ' '); const gunType = 'clip' in turretGunEntry ? turretGunEntry.pumpGunMode @@ -380,7 +380,7 @@ export async function buildDefinitions() { tankDefinitions[tankId].turrets[turretIndex].guns.push({ id: gunId, name: gunName, - tier: gun.level as Tier, + tier: gunListEntry.level as Tier, shells: [], type: gunType, reload: gunReload, @@ -413,19 +413,23 @@ export async function buildDefinitions() { }, }; - Object.keys(gun.shots).forEach((shellKey) => { - const turretShellEntry = gun.shots[shellKey]; + Object.keys(gunListEntry.shots).forEach((shellKey) => { + const gunShellEntry = gunListEntry.shots[shellKey]; const shell = shellList.root[shellKey]; const shellId = toUniqueId(nation, shell.id); const shellName = strings[shell.userString] ?? shellKey.replaceAll('_', ' '); + const penetrationRaw = gunShellEntry.piercingPower + .split(' ') + .filter((penetrationString) => penetrationString !== '') + .map(Number); tankDefinitions[tankId].turrets[turretIndex].guns[ gunIndex ].shells.push({ id: shellId, name: shellName, - speed: turretShellEntry.speed, + speed: gunShellEntry.speed, damage: { armor: shell.damage.armor, devices: shell.damage.devices, @@ -435,6 +439,10 @@ export async function buildDefinitions() { ricochet: shell.ricochetAngle, type: blitzShellKindToBLitzkrieg[shell.kind], icon: shell.icon, + penetration: + penetrationRaw[0] === penetrationRaw[1] + ? penetrationRaw[0] + : [penetrationRaw[0], penetrationRaw[1]], }); }); }); diff --git a/src/core/blitzkrieg/tankDefinitions.ts b/src/core/blitzkrieg/tankDefinitions.ts index 157e731fe..0f96c84c0 100644 --- a/src/core/blitzkrieg/tankDefinitions.ts +++ b/src/core/blitzkrieg/tankDefinitions.ts @@ -1,4 +1,5 @@ import { deburr } from 'lodash'; +import { Vector2Tuple } from 'three'; import { TankType, TreeTypeString } from '../../components/Tanks'; import { asset } from './asset'; @@ -67,6 +68,7 @@ export interface ShellDefinition { ricochet: number; type: ShellType; icon: string; + penetration: number | Vector2Tuple; } export const tankDefinitions = fetch(asset('definitions/tanks.json'), {