feat: display drone statistics (DPS, range, capacity, ..) (#78)
This commit is contained in:
@@ -39,10 +39,13 @@ export const fullFits = [
|
||||
ship_type_id: 29984,
|
||||
description: "",
|
||||
items: [
|
||||
{ flag: 125, quantity: 1, type_id: 45626 },
|
||||
{ flag: 126, quantity: 1, type_id: 45591 },
|
||||
{ flag: 127, quantity: 1, type_id: 45601 },
|
||||
{ flag: 128, quantity: 1, type_id: 45615 },
|
||||
{ flag: 5, quantity: 1, type_id: 35794 },
|
||||
{ flag: 5, quantity: 1, type_id: 35794 },
|
||||
{ flag: 5, quantity: 1, type_id: 35795 },
|
||||
{ flag: 5, quantity: 3720, type_id: 24492 },
|
||||
{ flag: 5, quantity: 396, type_id: 24492 },
|
||||
{ flag: 5, quantity: 5472, type_id: 2679 },
|
||||
{ flag: 5, quantity: 8, type_id: 30486 },
|
||||
{ flag: 11, quantity: 1, type_id: 22291 },
|
||||
{ flag: 12, quantity: 1, type_id: 22291 },
|
||||
{ flag: 13, quantity: 1, type_id: 22291 },
|
||||
@@ -63,13 +66,10 @@ export const fullFits = [
|
||||
{ flag: 92, quantity: 1, type_id: 31724 },
|
||||
{ flag: 93, quantity: 1, type_id: 31824 },
|
||||
{ flag: 94, quantity: 1, type_id: 31378 },
|
||||
{ flag: 5, quantity: 3720, type_id: 24492 },
|
||||
{ flag: 5, quantity: 5472, type_id: 2679 },
|
||||
{ flag: 5, quantity: 1, type_id: 35795 },
|
||||
{ flag: 5, quantity: 1, type_id: 35794 },
|
||||
{ flag: 5, quantity: 8, type_id: 30486 },
|
||||
{ flag: 5, quantity: 1, type_id: 35794 },
|
||||
{ flag: 5, quantity: 396, type_id: 24492 },
|
||||
{ flag: 125, quantity: 1, type_id: 45626 },
|
||||
{ flag: 126, quantity: 1, type_id: 45591 },
|
||||
{ flag: 127, quantity: 1, type_id: 45601 },
|
||||
{ flag: 128, quantity: 1, type_id: 45615 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -77,37 +77,76 @@ export const fullFits = [
|
||||
ship_type_id: 29986,
|
||||
description: "",
|
||||
items: [
|
||||
{ flag: 21, quantity: 1, type_id: 527 },
|
||||
{ flag: 19, quantity: 1, type_id: 2024 },
|
||||
{ flag: 5, quantity: 1, type_id: 32014 },
|
||||
{ flag: 5, quantity: 1, type_id: 33474 },
|
||||
{ flag: 5, quantity: 2, type_id: 30832 },
|
||||
{ flag: 5, quantity: 2, type_id: 30834 },
|
||||
{ flag: 5, quantity: 6, type_id: 12826 },
|
||||
{ flag: 11, quantity: 1, type_id: 3530 },
|
||||
{ flag: 12, quantity: 1, type_id: 14072 },
|
||||
{ flag: 13, quantity: 1, type_id: 14072 },
|
||||
{ flag: 14, quantity: 1, type_id: 5839 },
|
||||
{ flag: 15, quantity: 1, type_id: 2364 },
|
||||
{ flag: 19, quantity: 1, type_id: 2024 },
|
||||
{ flag: 20, quantity: 1, type_id: 3244 },
|
||||
{ flag: 21, quantity: 1, type_id: 527 },
|
||||
{ flag: 22, quantity: 1, type_id: 35656 },
|
||||
{ flag: 27, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 28, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 29, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 30, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 31, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 32, quantity: 1, type_id: 3025, charge: { type_id: 253 } },
|
||||
{ flag: 20, quantity: 1, type_id: 3244 },
|
||||
{ flag: 11, quantity: 1, type_id: 3530 },
|
||||
{ flag: 14, quantity: 1, type_id: 5839 },
|
||||
{ flag: 34, quantity: 1, type_id: 11578 },
|
||||
{ flag: 5, quantity: 6, type_id: 12826 },
|
||||
{ flag: 12, quantity: 1, type_id: 14072 },
|
||||
{ flag: 13, quantity: 1, type_id: 14072 },
|
||||
{ flag: 33, quantity: 1, type_id: 28756 },
|
||||
{ flag: 5, quantity: 2, type_id: 30832 },
|
||||
{ flag: 5, quantity: 2, type_id: 30834 },
|
||||
{ flag: 34, quantity: 1, type_id: 11578 },
|
||||
{ flag: 92, quantity: 1, type_id: 31055 },
|
||||
{ flag: 94, quantity: 1, type_id: 31071 },
|
||||
{ flag: 93, quantity: 1, type_id: 31215 },
|
||||
{ flag: 5, quantity: 1, type_id: 32014 },
|
||||
{ flag: 5, quantity: 1, type_id: 33474 },
|
||||
{ flag: 22, quantity: 1, type_id: 35656 },
|
||||
{ flag: 126, quantity: 1, type_id: 45586 },
|
||||
{ flag: 128, quantity: 1, type_id: 45598 },
|
||||
{ flag: 94, quantity: 1, type_id: 31071 },
|
||||
{ flag: 125, quantity: 1, type_id: 45612 },
|
||||
{ flag: 126, quantity: 1, type_id: 45586 },
|
||||
{ flag: 127, quantity: 1, type_id: 45622 },
|
||||
{ flag: 128, quantity: 1, type_id: 45598 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Loki",
|
||||
ship_type_id: 29990,
|
||||
description: "",
|
||||
items: [
|
||||
{ flag: 5, quantity: 1, type_id: 33700 },
|
||||
{ flag: 5, quantity: 150, type_id: 28668 },
|
||||
{ flag: 5, quantity: 16, type_id: 30486 },
|
||||
{ flag: 5, quantity: 16, type_id: 30488 },
|
||||
{ flag: 5, quantity: 330, type_id: 2679 },
|
||||
{ flag: 5, quantity: 9000, type_id: 13856 },
|
||||
{ flag: 5, quantity: 9000, type_id: 24488 },
|
||||
{ flag: 11, quantity: 1, type_id: 22291 },
|
||||
{ flag: 12, quantity: 1, type_id: 22291 },
|
||||
{ flag: 19, quantity: 1, type_id: 19203 },
|
||||
{ flag: 20, quantity: 1, type_id: 19289 },
|
||||
{ flag: 21, quantity: 1, type_id: 2281 },
|
||||
{ flag: 22, quantity: 1, type_id: 17500 },
|
||||
{ flag: 23, quantity: 1, type_id: 14142 },
|
||||
{ flag: 24, quantity: 1, type_id: 41220 },
|
||||
{ flag: 25, quantity: 1, type_id: 14108 },
|
||||
{ flag: 27, quantity: 1, type_id: 25715, charge: { type_id: 24488 } },
|
||||
{ flag: 28, quantity: 1, type_id: 25715, charge: { type_id: 24488 } },
|
||||
{ flag: 29, quantity: 1, type_id: 25715, charge: { type_id: 24488 } },
|
||||
{ flag: 30, quantity: 1, type_id: 25715, charge: { type_id: 24488 } },
|
||||
{ flag: 31, quantity: 1, type_id: 25715, charge: { type_id: 24488 } },
|
||||
{ flag: 32, quantity: 1, type_id: 30836 },
|
||||
{ flag: 33, quantity: 1, type_id: 11578 },
|
||||
{ flag: 34, quantity: 1, type_id: 28756, charge: { type_id: 30488 } },
|
||||
{ flag: 87, quantity: 5, type_id: 2456 },
|
||||
{ flag: 92, quantity: 1, type_id: 31748 },
|
||||
{ flag: 93, quantity: 1, type_id: 31760 },
|
||||
{ flag: 94, quantity: 1, type_id: 31588 },
|
||||
{ flag: 125, quantity: 1, type_id: 45633 },
|
||||
{ flag: 126, quantity: 1, type_id: 45595 },
|
||||
{ flag: 127, quantity: 1, type_id: 45608 },
|
||||
{ flag: 128, quantity: 1, type_id: 45621 },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const fullFit = fullFits[0];
|
||||
export const fullFit = fullFits[2];
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"typescript-plugin-css-modules": "^5.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@eveshipfit/dogma-engine": "^3.0.0",
|
||||
"@eveshipfit/dogma-engine": "^3.2.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Decorator, Meta, StoryObj } from "@storybook/react";
|
||||
import React from "react";
|
||||
|
||||
import { fullFits } from "../../.storybook/fits";
|
||||
import { fullFit } from "../../.storybook/fits";
|
||||
|
||||
import { DogmaEngineProvider } from "../DogmaEngineProvider";
|
||||
import { EsiProvider } from "../EsiProvider";
|
||||
@@ -43,7 +43,7 @@ export const Default: Story = {
|
||||
decorators: [useShipSnapshotProvider],
|
||||
parameters: {
|
||||
snapshot: {
|
||||
fit: fullFits[1],
|
||||
fit: fullFit,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from "react";
|
||||
import { EveDataContext } from "../EveDataProvider";
|
||||
import { ShipSnapshotContext } from "../ShipSnapshotProvider";
|
||||
|
||||
export interface ShipAttributeProps {
|
||||
export interface AttributeProps {
|
||||
/** Name of the attribute. */
|
||||
name: string;
|
||||
/** How many decimals to render. */
|
||||
@@ -17,13 +17,18 @@ export interface ShipAttributeProps {
|
||||
/**
|
||||
* Return the value of a ship's attribute.
|
||||
*/
|
||||
export function useShipAttribute(props: ShipAttributeProps) {
|
||||
export function useAttribute(type: "Ship" | "Char", props: AttributeProps) {
|
||||
const eveData = React.useContext(EveDataContext);
|
||||
const shipSnapshot = React.useContext(ShipSnapshotContext);
|
||||
|
||||
if (shipSnapshot?.loaded) {
|
||||
const attributeId = eveData.attributeMapping?.[props.name] || 0;
|
||||
let value = shipSnapshot.hull?.attributes.get(attributeId)?.value;
|
||||
let value;
|
||||
if (type === "Ship") {
|
||||
value = shipSnapshot.hull?.attributes.get(attributeId)?.value;
|
||||
} else {
|
||||
value = shipSnapshot.char?.attributes.get(attributeId)?.value;
|
||||
}
|
||||
let highIsGood = eveData.dogmaAttributes?.[attributeId]?.highIsGood;
|
||||
|
||||
if (value == undefined) {
|
||||
@@ -63,10 +68,19 @@ export function useShipAttribute(props: ShipAttributeProps) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a single attribute of a ship's snapshot.
|
||||
* Render a single ship attribute of a ship's snapshot.
|
||||
*/
|
||||
export const ShipAttribute = (props: ShipAttributeProps) => {
|
||||
const stringValue = useShipAttribute(props);
|
||||
export const ShipAttribute = (props: AttributeProps) => {
|
||||
const stringValue = useAttribute("Ship", props);
|
||||
|
||||
return <span>{stringValue}</span>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render a single character attribute of a ship's snapshot.
|
||||
*/
|
||||
export const CharAttribute = (props: AttributeProps) => {
|
||||
const stringValue = useAttribute("Char", props);
|
||||
|
||||
return <span>{stringValue}</span>;
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { useShipAttribute, ShipAttribute } from "./ShipAttribute";
|
||||
export { useAttribute, CharAttribute, ShipAttribute } from "./ShipAttribute";
|
||||
|
||||
@@ -31,7 +31,9 @@ const DroneBay = () => {
|
||||
<Icon name="drone-bay" size={32} />
|
||||
</div>
|
||||
<div className={styles.cargoText}>
|
||||
<div>0</div>
|
||||
<div>
|
||||
<ShipAttribute name="droneCapacityUsed" fixed={1} />
|
||||
</div>
|
||||
<div>
|
||||
/ <ShipAttribute name="droneCapacity" fixed={1} />
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React from "react";
|
||||
|
||||
import { useShipAttribute } from "../ShipAttribute";
|
||||
import { useAttribute } from "../ShipAttribute";
|
||||
|
||||
import styles from "./ShipStatistics.module.css";
|
||||
import clsx from "clsx";
|
||||
import { IconName, Icon } from "../Icon";
|
||||
|
||||
export const RechargeRateItem = (props: { name: string; icon: IconName }) => {
|
||||
const stringValue = useShipAttribute({
|
||||
const stringValue = useAttribute("Ship", {
|
||||
name: props.name,
|
||||
fixed: 1,
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from "react";
|
||||
|
||||
import { useShipAttribute } from "../ShipAttribute";
|
||||
import { useAttribute } from "../ShipAttribute";
|
||||
|
||||
import styles from "./ShipStatistics.module.css";
|
||||
|
||||
export const Resistance = (props: { name: string }) => {
|
||||
const stringValue = useShipAttribute({
|
||||
const stringValue = useAttribute("Ship", {
|
||||
name: props.name,
|
||||
fixed: 0,
|
||||
isResistance: true,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { Resistance } from "./Resistance";
|
||||
|
||||
import styles from "./ShipStatistics.module.css";
|
||||
import { Icon } from "../Icon";
|
||||
import { CharAttribute } from "../ShipAttribute/ShipAttribute";
|
||||
|
||||
/**
|
||||
* Render ship statistics similar to how it is done in-game.
|
||||
@@ -264,6 +265,49 @@ export const ShipStatistics = () => {
|
||||
</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>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const defaultDataUrl = "https://data.eveship.fit/v8.0-20240227/";
|
||||
export const defaultDataUrl = "https://data.eveship.fit/v9.1.0-20240227/";
|
||||
|
||||
Reference in New Issue
Block a user