Skip to content

Commit

Permalink
fix: render less statistics for Structures (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain authored May 10, 2024
1 parent 48a1879 commit e9b8da4
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 88 deletions.
45 changes: 45 additions & 0 deletions .storybook/fits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,51 @@ export const fullFits = [
{ flag: 128, quantity: 1, type_id: 45621 },
],
},
{
ship_type_id: 35833,
name: "Killmail 117621358",
description: "",
items: [
{ flag: 5, type_id: 37821, quantity: 6 },
{ flag: 5, type_id: 37822, quantity: 7 },
{ flag: 5, type_id: 37823, quantity: 7 },
{ flag: 5, type_id: 37824, quantity: 7 },
{ flag: 5, type_id: 37843, quantity: 6102 },
{ flag: 5, type_id: 37844, quantity: 4249 },
{ flag: 5, type_id: 63195, quantity: 17200 },
{ flag: 11, type_id: 47362, quantity: 1 },
{ flag: 12, type_id: 47342, quantity: 1 },
{ flag: 13, type_id: 47362, quantity: 1 },
{ flag: 14, type_id: 47362, quantity: 1 },
{ flag: 19, type_id: 35944, quantity: 1 },
{ flag: 20, type_id: 47334, quantity: 1 },
{ flag: 21, type_id: 47366, quantity: 1 },
{ flag: 22, type_id: 47338, quantity: 1 },
{ flag: 23, type_id: 47338, quantity: 1 },
{ flag: 27, type_id: 47327, quantity: 1 },
{ flag: 28, type_id: 47323, quantity: 1 },
{ flag: 29, type_id: 47323, quantity: 1 },
{ flag: 30, type_id: 47323, quantity: 1 },
{ flag: 31, type_id: 47330, quantity: 1 },
{ flag: 32, type_id: 47330, quantity: 1 },
{ flag: 92, type_id: 37254, quantity: 1 },
{ flag: 93, type_id: 37258, quantity: 1 },
{ flag: 94, type_id: 37260, quantity: 1 },
{ flag: 158, type_id: 47035, quantity: 10 },
{ flag: 158, type_id: 47037, quantity: 10 },
{ flag: 158, type_id: 47119, quantity: 12 },
{ flag: 158, type_id: 47123, quantity: 6 },
{ flag: 158, type_id: 47127, quantity: 6 },
{ flag: 158, type_id: 47127, quantity: 6 },
{ flag: 158, type_id: 47136, quantity: 3 },
{ flag: 158, type_id: 47141, quantity: 2 },
{ flag: 158, type_id: 47141, quantity: 6 },
{ flag: 158, type_id: 47143, quantity: 9 },
{ flag: 164, type_id: 35894, quantity: 1 },
{ flag: 172, type_id: 4246, quantity: 14030 },
{ flag: 180, type_id: 56204, quantity: 1 },
],
},
];

export const fullFit = fullFits[2];
9 changes: 8 additions & 1 deletion src/ShipFitExtended/ShipFitExtended.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ShipSnapshotContext } from "../ShipSnapshotProvider";
import styles from "./ShipFitExtended.module.css";
import clsx from "clsx";
import { DroneBay } from "../DroneBay";
import { EveDataContext } from "../EveDataProvider";

const ShipCargoHold = () => {
return (
Expand All @@ -27,8 +28,13 @@ const ShipCargoHold = () => {
};

const ShipDroneBay = () => {
const eveData = React.useContext(EveDataContext);
const shipSnapshot = React.useContext(ShipSnapshotContext);

const [isOpen, setIsOpen] = React.useState(false);

const isStructure = eveData.typeIDs?.[shipSnapshot?.hull?.type_id ?? 0]?.categoryID === 65;

return (
<>
<div onClick={() => setIsOpen(!isOpen)} className={styles.droneBay}>
Expand All @@ -40,7 +46,8 @@ const ShipDroneBay = () => {
<ShipAttribute name="droneCapacityUsed" fixed={1} />
</div>
<div>
/ <ShipAttribute name="droneCapacity" fixed={1} />
/ {isStructure && <>0.0</>}
{!isStructure && <ShipAttribute name="droneCapacity" fixed={1} />}
</div>
</div>
<div className={styles.cargoPostfix}>m3</div>
Expand Down
179 changes: 92 additions & 87 deletions src/ShipStatistics/ShipStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ShipStatistics = () => {
const shipSnapshot = React.useContext(ShipSnapshotContext);

let capacitorState = "Stable";
const isStructure = eveData.typeIDs?.[shipSnapshot?.hull?.type_id ?? 0]?.categoryID === 65;

if (shipSnapshot?.loaded) {
const attributeId = eveData.attributeMapping?.capacitorDepletesIn || 0;
Expand Down Expand Up @@ -220,94 +221,98 @@ export const ShipStatistics = () => {
</CategoryLine>
</Category>

<Category
headerLabel="Navigation"
headerContent={
<span>
<ShipAttribute name="maxVelocity" fixed={1} /> m/s
</span>
}
>
<CategoryLine>
<span title="Mass" className={styles.statistic}>
<span>
<Icon name="mass" size={24} />
</span>
<span>
<ShipAttribute name="mass" fixed={2} divideBy={1000} /> t
</span>
</span>
<span title="Inertia Modifier" className={styles.statistic}>
<span>
<Icon name="inertia-modifier" size={24} />
</span>
<span>
<ShipAttribute name="agility" fixed={4} />x
</span>
</span>
</CategoryLine>
<CategoryLine>
<span title="Ship Warp Speed" className={styles.statistic}>
<span>
<Icon name="warp-speed" size={24} />
</span>
<span>
<ShipAttribute name="warpSpeedMultiplier" fixed={2} /> AU/s
</span>
</span>
<span title="Align Time" className={styles.statistic}>
<span>
<Icon name="align-time" size={24} />
</span>
<span>
<ShipAttribute name="alignTime" fixed={2} />s
</span>
</span>
</CategoryLine>
</Category>
{!isStructure && (
<Category
headerLabel="Navigation"
headerContent={
<span>
<ShipAttribute name="maxVelocity" fixed={1} /> m/s
</span>
}
>
<CategoryLine>
<span title="Mass" className={styles.statistic}>
<span>
<Icon name="mass" size={24} />
</span>
<span>
<ShipAttribute name="mass" fixed={2} divideBy={1000} /> t
</span>
</span>
<span title="Inertia Modifier" className={styles.statistic}>
<span>
<Icon name="inertia-modifier" size={24} />
</span>
<span>
<ShipAttribute name="agility" fixed={4} />x
</span>
</span>
</CategoryLine>
<CategoryLine>
<span title="Ship Warp Speed" className={styles.statistic}>
<span>
<Icon name="warp-speed" size={24} />
</span>
<span>
<ShipAttribute name="warpSpeedMultiplier" fixed={2} /> AU/s
</span>
</span>
<span title="Align Time" className={styles.statistic}>
<span>
<Icon name="align-time" size={24} />
</span>
<span>
<ShipAttribute name="alignTime" fixed={2} />s
</span>
</span>
</CategoryLine>
</Category>
)}

<Category
headerLabel="Drones"
headerContent={
<span>
<ShipAttribute name="droneDamageDps" fixed={1} /> dps
</span>
}
>
<CategoryLine>
<span title="Drone Bandwidth" className={styles.statistic}>
<span>
<Icon name="mass" size={24} />
</span>
<span>
<ShipAttribute name="droneBandwidthUsedTotal" fixed={0} />/
<ShipAttribute name="droneBandwidth" fixed={0} /> Mbit/sec
</span>
</span>
<span title="Drone Control Range" className={styles.statistic}>
<span>
<Icon name="inertia-modifier" size={24} />
</span>
<span>
<CharAttribute name="droneControlDistance" fixed={2} divideBy={1000} /> km
</span>
</span>
</CategoryLine>
<CategoryLine>
<span className={styles.statistic}>
<span>
<div style={{ width: 24 }}></div>
</span>
<span>
<ShipAttribute name="droneActive" fixed={0} /> Active
</span>
</span>
<span className={styles.statistic}>
<span></span>
<span></span>
</span>
</CategoryLine>
</Category>
{!isStructure && (
<Category
headerLabel="Drones"
headerContent={
<span>
<ShipAttribute name="droneDamageDps" fixed={1} /> dps
</span>
}
>
<CategoryLine>
<span title="Drone Bandwidth" className={styles.statistic}>
<span>
<Icon name="mass" size={24} />
</span>
<span>
<ShipAttribute name="droneBandwidthUsedTotal" fixed={0} />/
<ShipAttribute name="droneBandwidth" fixed={0} /> Mbit/sec
</span>
</span>
<span title="Drone Control Range" className={styles.statistic}>
<span>
<Icon name="inertia-modifier" size={24} />
</span>
<span>
<CharAttribute name="droneControlDistance" fixed={2} divideBy={1000} /> km
</span>
</span>
</CategoryLine>
<CategoryLine>
<span className={styles.statistic}>
<span>
<div style={{ width: 24 }}></div>
</span>
<span>
<ShipAttribute name="droneActive" fixed={0} /> Active
</span>
</span>
<span className={styles.statistic}>
<span></span>
<span></span>
</span>
</CategoryLine>
</Category>
)}
</div>
);
};

0 comments on commit e9b8da4

Please sign in to comment.