feat: penetration

This commit is contained in:
TrèsAbhi committed 2024-01-10 17:36:11 -06:00
1 parent f9d0659bd4
commit 32ee10445d
2 files changed
+17 -7

No files matched your search

+15 -7
View File
@@ -315,9 +315,9 @@ export async function buildDefinitions() {
Object.keys(turret.guns).forEach((gunKey, gunIndex) => { Object.keys(turret.guns).forEach((gunKey, gunIndex) => {
const turretGunEntry = turret.guns[gunKey]; const turretGunEntry = turret.guns[gunKey];
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]); const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
const gun = gunList.root.shared[gunKey]; const gunListEntry = gunList.root.shared[gunKey];
const pitchLimitsRaw = const pitchLimitsRaw =
turretGunEntry.pitchLimits ?? gun.pitchLimits; turretGunEntry.pitchLimits ?? gunListEntry.pitchLimits;
const gunPitch = ( const gunPitch = (
typeof pitchLimitsRaw === 'string' typeof pitchLimitsRaw === 'string'
? pitchLimitsRaw ? pitchLimitsRaw
@@ -329,7 +329,7 @@ export async function buildDefinitions() {
parse(turretGunEntry.models.undamaged).name.split('_')[1], parse(turretGunEntry.models.undamaged).name.split('_')[1],
); );
const gunName = const gunName =
strings[gun.userString] ?? gunKey.replaceAll('_', ' '); strings[gunListEntry.userString] ?? gunKey.replaceAll('_', ' ');
const gunType = const gunType =
'clip' in turretGunEntry 'clip' in turretGunEntry
? turretGunEntry.pumpGunMode ? turretGunEntry.pumpGunMode
@@ -380,7 +380,7 @@ export async function buildDefinitions() {
tankDefinitions[tankId].turrets[turretIndex].guns.push({ tankDefinitions[tankId].turrets[turretIndex].guns.push({
id: gunId, id: gunId,
name: gunName, name: gunName,
tier: gun.level as Tier, tier: gunListEntry.level as Tier,
shells: [], shells: [],
type: gunType, type: gunType,
reload: gunReload, reload: gunReload,
@@ -413,19 +413,23 @@ export async function buildDefinitions() {
}, },
}; };
Object.keys(gun.shots).forEach((shellKey) => { Object.keys(gunListEntry.shots).forEach((shellKey) => {
const turretShellEntry = gun.shots[shellKey]; const gunShellEntry = gunListEntry.shots[shellKey];
const shell = shellList.root[shellKey]; const shell = shellList.root[shellKey];
const shellId = toUniqueId(nation, shell.id); const shellId = toUniqueId(nation, shell.id);
const shellName = const shellName =
strings[shell.userString] ?? shellKey.replaceAll('_', ' '); strings[shell.userString] ?? shellKey.replaceAll('_', ' ');
const penetrationRaw = gunShellEntry.piercingPower
.split(' ')
.filter((penetrationString) => penetrationString !== '')
.map(Number);
tankDefinitions[tankId].turrets[turretIndex].guns[ tankDefinitions[tankId].turrets[turretIndex].guns[
gunIndex gunIndex
].shells.push({ ].shells.push({
id: shellId, id: shellId,
name: shellName, name: shellName,
speed: turretShellEntry.speed, speed: gunShellEntry.speed,
damage: { damage: {
armor: shell.damage.armor, armor: shell.damage.armor,
devices: shell.damage.devices, devices: shell.damage.devices,
@@ -435,6 +439,10 @@ export async function buildDefinitions() {
ricochet: shell.ricochetAngle, ricochet: shell.ricochetAngle,
type: blitzShellKindToBLitzkrieg[shell.kind], type: blitzShellKindToBLitzkrieg[shell.kind],
icon: shell.icon, icon: shell.icon,
penetration:
penetrationRaw[0] === penetrationRaw[1]
? penetrationRaw[0]
: [penetrationRaw[0], penetrationRaw[1]],
}); });
}); });
}); });
+2
View File
@@ -1,4 +1,5 @@
import { deburr } from 'lodash'; import { deburr } from 'lodash';
import { Vector2Tuple } from 'three';
import { TankType, TreeTypeString } from '../../components/Tanks'; import { TankType, TreeTypeString } from '../../components/Tanks';
import { asset } from './asset'; import { asset } from './asset';
@@ -67,6 +68,7 @@ export interface ShellDefinition {
ricochet: number; ricochet: number;
type: ShellType; type: ShellType;
icon: string; icon: string;
penetration: number | Vector2Tuple;
} }
export const tankDefinitions = fetch(asset('definitions/tanks.json'), { export const tankDefinitions = fetch(asset('definitions/tanks.json'), {