Skip to content

Commit

Permalink
chore: bump data and dogma-engine to latest (#152)
Browse files Browse the repository at this point in the history
This renamed a few attributes to be more in line with others.
  • Loading branch information
TrueBrain authored Jul 6, 2024
1 parent 3f27913 commit 6b70fe0
Show file tree
Hide file tree
Showing 27 changed files with 126 additions and 117 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"typescript-plugin-css-modules": "^5"
},
"peerDependencies": {
"@eveshipfit/data": "^9",
"@eveshipfit/dogma-engine": "^5",
"@eveshipfit/data": "^10",
"@eveshipfit/dogma-engine": "^6",
"react": "^18",
"react-dom": "^18"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/CalculationDetail/CalculationDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const Effect = (props: { effect: CalculationItemAttributeEffect }) => {
if (item === undefined) {
sourceName = `Unknown ${sourceType}`;
} else {
sourceName = `${sourceType}: ` + (eveData.typeIDs?.[item?.type_id]?.name ?? sourceName);
sourceName = `${sourceType}: ` + (eveData.types?.[item?.type_id]?.name ?? sourceName);
attribute = item?.attributes.get(props.effect.source_attribute_id);

const itemState = stateToInteger(item.state);
Expand Down
6 changes: 3 additions & 3 deletions src/components/CargoBay/CargoBay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const CargoBayEntry = ({ name, cargo }: { name: string; cargo: EsfCargo }) => {
}, [fitManager, cargo]);

let slotType: CalculationSlotType | undefined = undefined;
if (eveData?.typeIDs[cargo.typeId]?.categoryID === 18) {
if (eveData?.types[cargo.typeId]?.categoryID === 18) {
slotType = "DroneBay";
} else if (eveData?.typeIDs[cargo.typeId]?.categoryID === 8) {
} else if (eveData?.types[cargo.typeId]?.categoryID === 8) {
slotType = "Charge";
} else {
slotType = eveData?.typeDogma[cargo.typeId]?.dogmaEffects
Expand Down Expand Up @@ -79,7 +79,7 @@ export const CargoBay = () => {
/* Fetch name of all cargo items. */
const cargoList: { name: string; item: EsfCargo }[] = [];
for (const item of currentFit.fit.cargo) {
const name = eveData.typeIDs?.[item.typeId].name ?? "";
const name = eveData.types?.[item.typeId].name ?? "";

cargoList.push({
name,
Expand Down
8 changes: 4 additions & 4 deletions src/components/DroneBay/DroneBay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ const DroneBayEntry = ({ name, drones }: { name: string; drones: CalculationItem

if (eveData === null || statistics === null) return <></>;

const attributeDroneBandwidthUsedTotal = eveData.attributeMapping.droneBandwidthUsedTotal ?? 0;
const attributeDroneBandwidthLoad = eveData.attributeMapping.droneBandwidthLoad ?? 0;
const attributeDroneActive = eveData.attributeMapping.droneActive ?? 0;
const attributeDroneBandwidthUsed = eveData.attributeMapping.droneBandwidthUsed ?? 0;
const attributeDroneBandwidth = eveData.attributeMapping.droneBandwidth ?? 0;
const attributeMaxActiveDrones = eveData.attributeMapping.maxActiveDrones ?? 0;

const bandwidthUsed = statistics.hull.attributes.get(attributeDroneBandwidthUsedTotal)?.value ?? 0;
const bandwidthLoad = statistics.hull.attributes.get(attributeDroneBandwidthLoad)?.value ?? 0;
const bandwidthAvailable = statistics.hull.attributes.get(attributeDroneBandwidth)?.value ?? 0;
const dronesActive = statistics.hull.attributes.get(attributeDroneActive)?.value ?? 0;
const maxDronesActive = statistics.char.attributes.get(attributeMaxActiveDrones)?.value ?? 0;
Expand All @@ -64,7 +64,7 @@ const DroneBayEntry = ({ name, drones }: { name: string; drones: CalculationItem

let maxOpen = Math.max(
0,
Math.min(maxDronesActive - dronesActive, Math.floor((bandwidthAvailable - bandwidthUsed) / droneBandwidth)),
Math.min(maxDronesActive - dronesActive, Math.floor((bandwidthAvailable - bandwidthLoad) / droneBandwidth)),
);
let index = 0;

Expand Down Expand Up @@ -104,7 +104,7 @@ export const DroneBay = () => {
/* Group drones by type_id */
const dronesGrouped: Record<string, CalculationItem[]> = {};
for (const drone of statistics.items.filter((item) => item.slot.type == "DroneBay")) {
const name = eveData.typeIDs?.[drone.type_id].name ?? "";
const name = eveData.types?.[drone.type_id].name ?? "";

if (dronesGrouped[name] === undefined) {
dronesGrouped[name] = [];
Expand Down
8 changes: 4 additions & 4 deletions src/components/HardwareListing/HardwareListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const HardwareListing = () => {

modules.push({
typeId: item.type_id,
name: eveData?.typeIDs?.[item.type_id].name ?? "Unknown",
name: eveData?.types?.[item.type_id].name ?? "Unknown",
chargeGroupIDs,
chargeSize: item.attributes.get(eveData?.attributeMapping.chargeSize ?? 0)?.value ?? -1,
});
Expand Down Expand Up @@ -190,8 +190,8 @@ export const HardwareListing = () => {
items: [],
};

for (const typeId in eveData.typeIDs) {
const module = eveData.typeIDs[typeId];
for (const typeId in eveData.types) {
const module = eveData.types[typeId];
/* Modules (7), Charges (8), Drones (18), Subsystems (32), and Structures (66) */
if (
module.categoryID !== 7 &&
Expand Down Expand Up @@ -267,7 +267,7 @@ export const HardwareListing = () => {
}
}

const shipGroup = eveData.typeIDs[shipType]?.groupID;
const shipGroup = eveData.types[shipType]?.groupID;

const canFitShipType = eveData.typeDogma[typeId]?.dogmaAttributes.filter(
(attr) =>
Expand Down
6 changes: 3 additions & 3 deletions src/components/HullListing/HullListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export const HullListing = () => {
const anyFilter = filter.localFits || filter.characterFits;

const grouped: ListingGroups = {};
for (const typeId in eveData.typeIDs) {
const hull = eveData.typeIDs[typeId];
for (const typeId in eveData.types) {
const hull = eveData.types[typeId];
if (hull.categoryID !== 6) continue;
if (hull.marketGroupID === undefined) continue;
if (!hull.published) continue;
Expand All @@ -230,7 +230,7 @@ export const HullListing = () => {

if (search !== "" && !hull.name.toLowerCase().includes(search.toLowerCase())) continue;

const group = eveData.groupIDs[hull.groupID]?.name ?? "Unknown Group";
const group = eveData.groups[hull.groupID]?.name ?? "Unknown Group";
const race = factionIdToRace[hull.factionID ?? 0] ?? "NonEmpire";

if (grouped[group] === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShipAttribute/ShipAttribute.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Default: Story = {
},
args: {
fit: null,
name: "cpuUsed",
name: "cpuLoad",
},
decorators: [withDecoratorFull],
render: ({ fit, ...args }) => {
Expand Down
16 changes: 12 additions & 4 deletions src/components/ShipAttribute/ShipAttribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ export function useAttribute(type: "Ship" | "Char", props: AttributeProps): { va
value = statistics.capacityUsed;
currentValue = currentStatistics?.capacityUsed;
} else if (type === "Ship") {
value = statistics.hull.attributes.get(attributeId)?.value;
currentValue = currentStatistics?.hull.attributes.get(attributeId)?.value;
value =
statistics.hull.attributes.get(attributeId)?.value || eveData?.dogmaAttributes[attributeId]?.defaultValue || 0;
currentValue =
currentStatistics?.hull.attributes.get(attributeId)?.value ||
eveData?.dogmaAttributes[attributeId]?.defaultValue ||
0;
} else {
value = statistics.char.attributes.get(attributeId)?.value;
currentValue = currentStatistics?.char.attributes.get(attributeId)?.value;
value =
statistics.char.attributes.get(attributeId)?.value || eveData?.dogmaAttributes[attributeId]?.defaultValue || 0;
currentValue =
currentStatistics?.char.attributes.get(attributeId)?.value ||
eveData?.dogmaAttributes[attributeId]?.defaultValue ||
0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/ShipFit/Hull.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Hull = () => {
<div className={styles.hull}>
<img
src={`https://images.evetech.net/types/${shipTypeId}/render?size=1024`}
alt={eveData.typeIDs[shipTypeId].name}
alt={eveData.types[shipTypeId].name}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ShipFit/Slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const Slot = (props: { type: EsfSlotType; index: number; fittable: boolea
item = (
<img
src={`https://images.evetech.net/types/${module.charge.type_id}/icon?size=64`}
title={`${eveData.typeIDs[module.type_id].name}\n${eveData.typeIDs[module.charge.type_id].name}`}
title={`${eveData.types[module.type_id].name}\n${eveData.types[module.charge.type_id].name}`}
draggable={true}
onDragStart={onDragStart}
/>
Expand All @@ -239,7 +239,7 @@ export const Slot = (props: { type: EsfSlotType; index: number; fittable: boolea
item = (
<img
src={`https://images.evetech.net/types/${module.type_id}/icon?size=64`}
title={eveData.typeIDs[module.type_id].name}
title={eveData.types[module.type_id].name}
draggable={true}
onDragStart={onDragStart}
className={clsx({ [styles.preview]: fitModule?.state === "Preview" })}
Expand Down
5 changes: 2 additions & 3 deletions src/components/ShipFit/Usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ export const Usage = (props: {

case "cpu":
usageTotal = statistics?.hull.attributes?.get(eveData.attributeMapping.cpuOutput ?? 0)?.value ?? 0;
usageUsed = usageTotal - (statistics?.hull.attributes?.get(eveData.attributeMapping.cpuUnused ?? 0)?.value ?? 0);
usageUsed = usageTotal - (statistics?.hull.attributes?.get(eveData.attributeMapping.cpuFree ?? 0)?.value ?? 0);
break;

case "pg":
usageTotal = statistics?.hull.attributes?.get(eveData.attributeMapping.powerOutput ?? 0)?.value ?? 0;
usageUsed =
usageTotal - (statistics?.hull.attributes?.get(eveData.attributeMapping.powerUnused ?? 0)?.value ?? 0);
usageUsed = usageTotal - (statistics?.hull.attributes?.get(eveData.attributeMapping.powerFree ?? 0)?.value ?? 0);
break;
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/ShipFitExtended/ShipFitExtended.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const ShipDroneBay = () => {

if (eveData === null) return <></>;

const isStructure = eveData.typeIDs[currentFit.currentFit?.shipTypeId ?? 0]?.categoryID === 65;
const isStructure = eveData.types[currentFit.currentFit?.shipTypeId ?? 0]?.categoryID === 65;

if (currentFit.fit?.drones.length === 0 && isOpen) {
setIsOpen(false);
Expand All @@ -100,7 +100,7 @@ const ShipDroneBay = () => {
</div>
<div className={styles.cargoText}>
<div>
<ShipAttribute name="droneCapacityUsed" fixed={1} />
<ShipAttribute name="droneCapacityLoad" fixed={1} />
</div>
<div>
/ {isStructure && <>0.0</>}
Expand Down Expand Up @@ -169,10 +169,10 @@ export const ShipFitExtended = (props: { isPreview?: boolean }) => {

<div className={styles.cpuPg}>
<CpuPg title="CPU">
<ShipAttribute name="cpuUnused" fixed={1} />/<ShipAttribute name="cpuOutput" fixed={1} />
<ShipAttribute name="cpuFree" fixed={1} />/<ShipAttribute name="cpuOutput" fixed={1} />
</CpuPg>
<CpuPg title="Power Grid">
<ShipAttribute name="powerUnused" fixed={1} />/<ShipAttribute name="powerOutput" fixed={1} />
<ShipAttribute name="powerFree" fixed={1} />/<ShipAttribute name="powerOutput" fixed={1} />
</CpuPg>
</div>

Expand Down
12 changes: 7 additions & 5 deletions src/components/ShipStatistics/RechargeRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RechargeRateItem = (props: { name: string; icon: IconName }) => {
};

export const RechargeRate = () => {
const [moduleType, setModuleType] = React.useState("passiveShieldRecharge");
const [moduleType, setModuleType] = React.useState("passiveShieldRechargeRate");
const [showDropdown, setShowDropdown] = React.useState(false);

return (
Expand Down Expand Up @@ -64,10 +64,12 @@ export const RechargeRate = () => {
</div>
<div
onClick={() => {
setModuleType("passiveShieldRecharge");
setModuleType("passiveShieldRechargeRate");
setShowDropdown(false);
}}
className={clsx({ [styles.rechargeRateDropdownContentSelected]: moduleType == "passiveShieldRecharge" })}
className={clsx({
[styles.rechargeRateDropdownContentSelected]: moduleType == "passiveShieldRechargeRate",
})}
>
Passive shield recharge
</div>
Expand All @@ -85,8 +87,8 @@ export const RechargeRate = () => {
<div onClick={() => setShowDropdown((current) => !current)}>
{moduleType == "armorRepairRate" && <RechargeRateItem name="armorRepairRate" icon="armor-repair-rate" />}
{moduleType == "hullRepairRate" && <RechargeRateItem name="hullRepairRate" icon="hull-repair-rate" />}
{moduleType == "passiveShieldRecharge" && (
<RechargeRateItem name="passiveShieldRecharge" icon="passive-shield-recharge" />
{moduleType == "passiveShieldRechargeRate" && (
<RechargeRateItem name="passiveShieldRechargeRate" icon="passive-shield-recharge" />
)}
{moduleType == "shieldBoostRate" && <RechargeRateItem name="shieldBoostRate" icon="shield-boost-rate" />}
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/components/ShipStatistics/ShipStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ShipStatistics = () => {
const statistics = useStatistics();

let capacitorState = "Stable";
const isStructure = eveData?.typeIDs[currentFit.currentFit?.shipTypeId ?? 0]?.categoryID === 65;
const isStructure = eveData?.types[currentFit.currentFit?.shipTypeId ?? 0]?.categoryID === 65;

const attributeId = eveData?.attributeMapping.capacitorDepletesIn ?? 0;
const capacitorDepletesIn = statistics?.hull.attributes.get(attributeId)?.value;
Expand Down Expand Up @@ -71,7 +71,7 @@ export const ShipStatistics = () => {
headerLabel="Offense"
headerContent={
<span>
<ShipAttribute name="damageWithoutReloadDps" fixed={1} unit="dps" />
<ShipAttribute name="damagePerSecondWithoutReload" fixed={1} unit="dps" />
</span>
}
>
Expand All @@ -81,16 +81,16 @@ export const ShipStatistics = () => {
<Icon name="damage-dps" size={24} />
</span>
<span>
<ShipAttribute name="damageWithoutReloadDps" fixed={1} unit="dps" /> (
<ShipAttribute name="damageWithReloadDps" fixed={1} unit="dps" />)
<ShipAttribute name="damagePerSecondWithoutReload" fixed={1} unit="dps" /> (
<ShipAttribute name="damagePerSecondWithReload" fixed={1} unit="dps" />)
</span>
</span>
<span title="Alpha Strike" className={styles.statistic}>
<span>
<Icon name="damage-alpha" size={24} />
</span>
<span>
<ShipAttribute name="damageAlphaHp" fixed={0} unit="HP" />
<ShipAttribute name="damageAlpha" fixed={0} unit="HP" />
</span>
</span>
</CategoryLine>
Expand Down Expand Up @@ -273,7 +273,7 @@ export const ShipStatistics = () => {
headerLabel="Drones"
headerContent={
<span>
<ShipAttribute name="droneDamageDps" fixed={1} unit="dps" />
<ShipAttribute name="droneDamagePerSecond" fixed={1} unit="dps" />
</span>
}
>
Expand All @@ -283,7 +283,7 @@ export const ShipStatistics = () => {
<Icon name="mass" size={24} />
</span>
<span>
<ShipAttribute name="droneBandwidthUsedTotal" fixed={0} />/
<ShipAttribute name="droneBandwidthLoad" fixed={0} />/
<ShipAttribute name="droneBandwidth" fixed={0} /> Mbit/sec
</span>
</span>
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/ExportEft/ExportEft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function useExportEft() {

let eft = "";

const shipType = eveData.typeIDs[fit.shipTypeId];
const shipType = eveData.types[fit.shipTypeId];
if (shipType === undefined) return null;

eft += `[${shipType.name}, ${fit.name}]\n`;
Expand All @@ -41,15 +41,15 @@ export function useExportEft() {
continue;
}

const moduleType = eveData.typeIDs[module.typeId];
const moduleType = eveData.types[module.typeId];
if (moduleType === undefined) {
eft += "[Empty " + slotToEft[slotType] + "]\n";
continue;
}

eft += moduleType.name;
if (module.charge !== undefined) {
const chargeType = eveData.typeIDs[module.charge.typeId];
const chargeType = eveData.types[module.charge.typeId];
if (chargeType !== undefined) {
eft += `, ${chargeType.name}`;
}
Expand All @@ -64,7 +64,7 @@ export function useExportEft() {
eft += "\n";

for (const drone of fit.drones) {
const droneType = eveData.typeIDs[drone.typeId];
const droneType = eveData.types[drone.typeId];
if (droneType === undefined) continue;

eft += droneType.name;
Expand All @@ -76,7 +76,7 @@ export function useExportEft() {
eft += "\n";

for (const cargo of fit.cargo) {
const cargoType = eveData.typeIDs[cargo.typeId];
const cargoType = eveData.types[cargo.typeId];
if (cargoType === undefined) continue;

eft += `${cargoType.name} x${cargo.quantity}`;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/ImportEft/ImportEft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function useImportEft() {
if (eveData === null) return null;

function lookupTypeByName(name: string): number | undefined {
for (const typeId in eveData?.typeIDs) {
const type = eveData.typeIDs[typeId];
for (const typeId in eveData?.types) {
const type = eveData.types[typeId];

if (type.name === name) {
return parseInt(typeId);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/ImportEveShipFit/DecodeKillMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function useFetchKillMail() {
modules = modules
.map((moduleOrCharge) => {
/* Looks for items that are charges. */
if (eveData.typeIDs[moduleOrCharge.typeId]?.categoryID !== 8) return moduleOrCharge;
if (eveData.types[moduleOrCharge.typeId]?.categoryID !== 8) return moduleOrCharge;

/* Find the module on the same slot. */
const module = modules.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface DefaultCharacterProps {

const CreateSkills = (eveData: EveData, level: number) => {
const skills: Skills = {};
for (const typeId in eveData.typeIDs) {
if (eveData.typeIDs[typeId].categoryID !== 16) continue;
for (const typeId in eveData.types) {
if (eveData.types[typeId].categoryID !== 16) continue;
skills[typeId] = level;
}

Expand Down
Loading

0 comments on commit 6b70fe0

Please sign in to comment.