diff --git a/package.json b/package.json index 8aebfb6..08a4ae0 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "typescript-plugin-css-modules": "^5.0.2" }, "peerDependencies": { - "@eveshipfit/dogma-engine": "^2.4.0", + "@eveshipfit/dogma-engine": "^2.5.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/src/ShipStatistics/ShipStatistics.module.css b/src/ShipStatistics/ShipStatistics.module.css index 407bb28..bdbfd06 100644 --- a/src/ShipStatistics/ShipStatistics.module.css +++ b/src/ShipStatistics/ShipStatistics.module.css @@ -145,3 +145,10 @@ .rechargeRateDropdownContent > div:hover { background-color: #4e4e4e; } + +.capacitorStable { + color: #8dc169; +} +.capacitorUnstable { + color: #ff454b; +} diff --git a/src/ShipStatistics/ShipStatistics.tsx b/src/ShipStatistics/ShipStatistics.tsx index 8356afa..fb9f2ae 100644 --- a/src/ShipStatistics/ShipStatistics.tsx +++ b/src/ShipStatistics/ShipStatistics.tsx @@ -2,6 +2,8 @@ import clsx from "clsx"; import React from "react"; import { ShipAttribute } from '../ShipAttribute'; +import { EveDataContext } from "../EveDataProvider"; +import { ShipSnapshotContext } from "../ShipSnapshotProvider"; import { Category, CategoryLine } from "./Category"; import { RechargeRate } from "./RechargeRate"; @@ -14,18 +16,37 @@ import { Icon } from "../Icon"; * Render ship statistics similar to how it is done in-game. */ export const ShipStatistics = () => { + const eveData = React.useContext(EveDataContext); + const shipSnapshot = React.useContext(ShipSnapshotContext); + + let capacitorState = "Stable"; + + if (shipSnapshot?.loaded) { + const attributeId = eveData.attributeMapping?.capacitorDepletesIn || 0; + const capacitorDepletesIn = shipSnapshot.hull?.attributes.get(attributeId)?.value; + + if (capacitorDepletesIn !== undefined && capacitorDepletesIn > 0) { + const hours = Math.floor(capacitorDepletesIn / 3600); + const minutes = Math.floor((capacitorDepletesIn % 3600) / 60); + const seconds = Math.floor(capacitorDepletesIn % 60); + capacitorState = `Depletes in ${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`; + } else { + capacitorState = "Stable"; + } + } + return
? + {capacitorState} }> - GJ / s + GJ / s - Δ GJ/s (%) + Δ GJ/s (%) diff --git a/src/settings.ts b/src/settings.ts index 58bbbb7..23b410a 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1 +1 @@ -export const defaultDataUrl = "https://data.eveship.fit/v7.0-20231214/"; +export const defaultDataUrl = "https://data.eveship.fit/v7.1-20231214/";