exclude 0 item groups

This commit is contained in:
tresabhi committed 2026-06-03 13:25:19 -05:00
1 parent 632989087c
commit 231e4aad0e
4 files changed
+30 -9

No files matched your search

+2 -1
View File
@@ -227,7 +227,8 @@
"burst_size": "Burst size", "burst_size": "Burst size",
"intra_burst": "Intra-burst", "intra_burst": "Intra-burst",
"penetration": "Penetration", "penetration": "Penetration",
"penetration_loss": "Penetration loss", "penetration_loss_by_distance": "Penetration loss by distance",
"penetration_loss_after_ricochet": "Penetration loss after ricochet",
"shell_velocity": "Shell velocity", "shell_velocity": "Shell velocity",
"shell_range": "Shell range", "shell_range": "Shell range",
"shell_capacity": "Shell capacity", "shell_capacity": "Shell capacity",
@@ -21,9 +21,16 @@ export function TankopediaCharacteristics({
return ( return (
<div className={styles["characteristics-wrapper"]}> <div className={styles["characteristics-wrapper"]}>
<div className={styles.characteristics}> <div className={styles.characteristics}>
{characteristicsOrder.map((group) => ( {characteristicsOrder.map((group) => {
<Group group={group} characteristics={characteristics} /> const items = group.order.filter(
))} (item) => "name" in item && characteristics[item.name] !== null,
).length;
const shouldRender = items > 0;
if (!shouldRender) return null;
return <Group group={group} characteristics={characteristics} />;
})}
</div> </div>
</div> </div>
); );
@@ -1,5 +1,6 @@
import { TankClass } from "@protos/blitz_static_tank_component"; import { TankClass } from "@protos/blitz_static_tank_component";
import { import {
ModuleUpgrade_AttributeName,
ShellUpgradeSingleChange_AttributeName, ShellUpgradeSingleChange_AttributeName,
StageParameters, StageParameters,
TankAttributeChange_AttributeName, TankAttributeChange_AttributeName,
@@ -8,7 +9,6 @@ import type { Tank } from "@protos/tank";
import { radToDeg } from "three/src/math/MathUtils.js"; import { radToDeg } from "three/src/math/MathUtils.js";
import { applyPitchYawLimits } from "./applyPitchYawLimits"; import { applyPitchYawLimits } from "./applyPitchYawLimits";
import { TerrainHardness, type TankState } from "./tankState"; import { TerrainHardness, type TankState } from "./tankState";
import { attribute } from "three/src/nodes/core/AttributeNode.js";
export type CharacteristicOutput = number | number[] | string | null; export type CharacteristicOutput = number | number[] | string | null;
@@ -458,7 +458,19 @@ export const characteristics = {
return -Infinity; return -Infinity;
}, },
penetration_loss() { penetration_loss_after_ricochet({ shell }) {
return -Infinity; const loss = shell(
ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_PIERCING_POWER_LOSS_AFTER_HIT,
);
return loss;
},
penetration_loss_by_distance({ attributeSafe }) {
const loss = attributeSafe(
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_SHELLS_PIERCING_POWER_LOSS_REDUCTION,
);
return loss ?? 0;
}, },
} satisfies Record<string, Characteristic>; } satisfies Record<string, Characteristic>;
@@ -143,13 +143,14 @@ export const characteristicsOrder: CharacteristicsGroup[] = [
render: CharacteristicsGroupRender.Statistical, render: CharacteristicsGroupRender.Statistical,
order: [ order: [
{ name: "penetration", units: "mm" }, { name: "penetration", units: "mm" },
{ name: "penetration_loss" }, { name: "penetration_loss_by_distance" },
{ name: "penetration_loss_after_ricochet" },
{ name: "shell_velocity", units: "m_s" }, { name: "shell_velocity", units: "m_s" },
{ name: "shell_range", units: "m" }, { name: "shell_range", units: "m" },
{ name: "shell_capacity" }, { name: "shell_capacity" },
{ name: "caliber", units: "mm" }, { name: "caliber", units: "mm" },
{ name: "normalization", units: "deg" },
{ name: "ricochet", units: "deg" }, { name: "ricochet", units: "deg" },
{ name: "normalization", units: "deg" },
{ toy: "ricochet" }, { toy: "ricochet" },
], ],