fix: compare remaining penetration with 0

This commit is contained in:
TrèsAbhi committed 2024-02-03 12:22:52 -06:00
1 parent d89575b25d
commit a212d2142c
2 files changed
+2 -6

No files matched your search

@@ -265,16 +265,12 @@ export function ArmorMesh({
if (gap) armorPiercingLayers.push(gap); if (gap) armorPiercingLayers.push(gap);
}); });
console.log(armorPiercingLayers);
let remainingPenetration = resolvedPenetration; let remainingPenetration = resolvedPenetration;
let accumulatedThickness = 0;
const explosiveCapable = isExplosive(shell.type); const explosiveCapable = isExplosive(shell.type);
armorPiercingLayers.forEach((layer) => { armorPiercingLayers.forEach((layer) => {
if (layer.type !== 'gap') { if (layer.type !== 'gap') {
remainingPenetration -= layer.angled; remainingPenetration -= layer.angled;
accumulatedThickness += layer.angled;
} else if (explosiveCapable) { } else if (explosiveCapable) {
// there is a 50% penetration loss per meter for HE based shells // there is a 50% penetration loss per meter for HE based shells
remainingPenetration -= 0.5 * remainingPenetration * layer.gap; remainingPenetration -= 0.5 * remainingPenetration * layer.gap;
@@ -286,7 +282,7 @@ export function ArmorMesh({
const hasRicochet = armorPiercingLayers.some( const hasRicochet = armorPiercingLayers.some(
(layer) => layer.type !== 'gap' && layer.ricochet, (layer) => layer.type !== 'gap' && layer.ricochet,
); );
const hasPenetrated = remainingPenetration >= accumulatedThickness; const hasPenetrated = remainingPenetration > 0;
mutateTankopediaTemporary((draft) => { mutateTankopediaTemporary((draft) => {
draft.shot = { draft.shot = {
+1 -1
View File
@@ -23,7 +23,7 @@ export const SHOT_ICONS: Record<Shot['type'], ReactNode> = {
}; };
const THICKNESS = 0.05; const THICKNESS = 0.05;
const LENGTH = 2; const LENGTH = 4;
export function ShotDisplay() { export function ShotDisplay() {
const shot = useTankopediaTemporary((state) => state.shot); const shot = useTankopediaTemporary((state) => state.shot);