chore: bump data and dogma-engine to latest (#152)
This renamed a few attributes to be more in line with others.
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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] = [];
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
@@ -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 &&
|
||||
@@ -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) =>
|
||||
|
||||
@@ -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;
|
||||
@@ -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) {
|
||||
|
||||
@@ -24,7 +24,7 @@ export const Default: Story = {
|
||||
},
|
||||
args: {
|
||||
fit: null,
|
||||
name: "cpuUsed",
|
||||
name: "cpuLoad",
|
||||
},
|
||||
decorators: [withDecoratorFull],
|
||||
render: ({ fit, ...args }) => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
@@ -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" })}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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</>}
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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 (
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
}
|
||||
>
|
||||
@@ -81,8 +81,8 @@ 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}>
|
||||
@@ -90,7 +90,7 @@ export const ShipStatistics = () => {
|
||||
<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>
|
||||
@@ -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>
|
||||
}
|
||||
>
|
||||
@@ -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>
|
||||
|
||||
@@ -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`;
|
||||
@@ -41,7 +41,7 @@ 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;
|
||||
@@ -49,7 +49,7 @@ export function useExportEft() {
|
||||
|
||||
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}`;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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}`;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,8 @@ export const EsiCharactersProvider = (props: EsiProps) => {
|
||||
if (esiFittings === undefined) return;
|
||||
|
||||
/* Ensure all skills are set; also those not learnt. */
|
||||
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;
|
||||
if (skills[typeId] !== undefined) continue;
|
||||
skills[typeId] = 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
DogmaEffect,
|
||||
TypeDogmaAttribute,
|
||||
TypeDogmaEffect,
|
||||
TypeID,
|
||||
Type,
|
||||
useEveData,
|
||||
} from "@/providers/EveDataProvider";
|
||||
import { EsfFit } from "@/providers/CurrentFitProvider";
|
||||
@@ -88,8 +88,8 @@ export const DogmaEngineProvider = (props: DogmaEngineProps) => {
|
||||
window.get_dogma_effect = (effect_id: number): DogmaEffect | undefined => {
|
||||
return eveData.dogmaEffects[effect_id];
|
||||
};
|
||||
window.get_type_id = (type_id: number): TypeID | undefined => {
|
||||
return eveData.typeIDs[type_id];
|
||||
window.get_type_id = (type_id: number): Type | undefined => {
|
||||
return eveData.types[type_id];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface TypeDogma {
|
||||
dogmaEffects: TypeDogmaEffect[];
|
||||
}
|
||||
|
||||
export interface TypeID {
|
||||
export interface Type {
|
||||
name: string;
|
||||
groupID: number;
|
||||
categoryID: number;
|
||||
@@ -27,7 +27,7 @@ export interface TypeID {
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
export interface GroupID {
|
||||
export interface Group {
|
||||
name: string;
|
||||
categoryID: number;
|
||||
published: boolean;
|
||||
|
||||
@@ -20,9 +20,9 @@ const TestEveData = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
TypeIDs: {Object.keys(eveData.typeIDs).length}
|
||||
Types: {Object.keys(eveData.types).length}
|
||||
<br />
|
||||
GroupIDs: {Object.keys(eveData.groupIDs).length}
|
||||
Groups: {Object.keys(eveData.groups).length}
|
||||
<br />
|
||||
MarketGroups: {Object.keys(eveData.marketGroups).length}
|
||||
<br />
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
|
||||
import { defaultDataUrl } from "@/settings";
|
||||
|
||||
import { DogmaAttribute, DogmaEffect, GroupID, MarketGroup, TypeDogma, TypeID } from "./DataTypes";
|
||||
import { DogmaAttribute, DogmaEffect, Group, MarketGroup, TypeDogma, Type } from "./DataTypes";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
@@ -10,8 +10,8 @@ import { DogmaAttribute, DogmaEffect, GroupID, MarketGroup, TypeDogma, TypeID }
|
||||
import * as esf_pb2 from "./esf_pb2.js";
|
||||
|
||||
export interface EveData {
|
||||
typeIDs: Record<string, TypeID>;
|
||||
groupIDs: Record<string, GroupID>;
|
||||
types: Record<string, Type>;
|
||||
groups: Record<string, Group>;
|
||||
marketGroups: Record<string, MarketGroup>;
|
||||
typeDogma: Record<string, TypeDogma>;
|
||||
dogmaEffects: Record<string, DogmaEffect>;
|
||||
@@ -47,8 +47,8 @@ async function fetchDataFile(dataUrl: string, name: string, pb2: any): Promise<o
|
||||
}
|
||||
|
||||
function isLoaded(dogmaData: EveData): boolean {
|
||||
if (Object.keys(dogmaData.typeIDs).length === 0) return false;
|
||||
if (Object.keys(dogmaData.groupIDs).length === 0) return false;
|
||||
if (Object.keys(dogmaData.types).length === 0) return false;
|
||||
if (Object.keys(dogmaData.groups).length === 0) return false;
|
||||
if (Object.keys(dogmaData.marketGroups).length === 0) return false;
|
||||
if (Object.keys(dogmaData.typeDogma).length === 0) return false;
|
||||
if (Object.keys(dogmaData.dogmaEffects).length === 0) return false;
|
||||
@@ -58,13 +58,13 @@ function isLoaded(dogmaData: EveData): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides information like TypeIDs, Dogma information, etc.
|
||||
* Provides information like types, Dogma information, etc.
|
||||
*
|
||||
* ```typescript
|
||||
* const eveData = useEveData();
|
||||
*
|
||||
* if (eveData !== null) {
|
||||
* console.log(eveData.typeIDs.length);
|
||||
* console.log(eveData.types.length);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@@ -72,8 +72,8 @@ export const EveDataProvider = (props: EveDataProps) => {
|
||||
const dataUrl = props.dataUrl ?? `${defaultDataUrl}sde/`;
|
||||
/* Initialize with empty data; we never set the context till everything is loaded. */
|
||||
const [dogmaData, setDogmaData] = React.useState<EveData>({
|
||||
typeIDs: {},
|
||||
groupIDs: {},
|
||||
types: {},
|
||||
groups: {},
|
||||
marketGroups: {},
|
||||
typeDogma: {},
|
||||
dogmaEffects: {},
|
||||
@@ -97,8 +97,8 @@ export const EveDataProvider = (props: EveDataProps) => {
|
||||
});
|
||||
}
|
||||
|
||||
fetchAndLoadDataFile("typeIDs", esf_pb2.esf.TypeIDs);
|
||||
fetchAndLoadDataFile("groupIDs", esf_pb2.esf.GroupIDs);
|
||||
fetchAndLoadDataFile("types", esf_pb2.esf.Types);
|
||||
fetchAndLoadDataFile("groups", esf_pb2.esf.Groups);
|
||||
fetchAndLoadDataFile("marketGroups", esf_pb2.esf.MarketGroups);
|
||||
fetchAndLoadDataFile("typeDogma", esf_pb2.esf.TypeDogma);
|
||||
fetchAndLoadDataFile("dogmaEffects", esf_pb2.esf.DogmaEffects);
|
||||
|
||||
@@ -195,9 +195,9 @@ export const esf = $root.esf = (() => {
|
||||
return TypeDogma;
|
||||
})();
|
||||
|
||||
esf.TypeIDs = (function() {
|
||||
esf.Types = (function() {
|
||||
|
||||
function TypeIDs(p) {
|
||||
function Types(p) {
|
||||
this.entries = {};
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
@@ -205,12 +205,12 @@ export const esf = $root.esf = (() => {
|
||||
this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
|
||||
TypeIDs.prototype.entries = emptyObject;
|
||||
Types.prototype.entries = emptyObject;
|
||||
|
||||
TypeIDs.decode = async function decode(r, l) {
|
||||
Types.decode = async function decode(r, l) {
|
||||
if (!(r instanceof $Reader))
|
||||
r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.TypeIDs(), k, value;
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.Types(), k, value;
|
||||
while (r.pos < c) {
|
||||
if (r.need_data()) {
|
||||
await r.fetch_data();
|
||||
@@ -232,7 +232,7 @@ export const esf = $root.esf = (() => {
|
||||
k = r.int32();
|
||||
break;
|
||||
case 2:
|
||||
value = $root.esf.TypeIDs.TypeID.decode(r, r.uint32());
|
||||
value = $root.esf.Types.Type.decode(r, r.uint32());
|
||||
break;
|
||||
default:
|
||||
r.skipType(tag2 & 7);
|
||||
@@ -250,31 +250,31 @@ export const esf = $root.esf = (() => {
|
||||
return m;
|
||||
};
|
||||
|
||||
TypeIDs.TypeID = (function() {
|
||||
Types.Type = (function() {
|
||||
|
||||
function TypeID(p) {
|
||||
function Type(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null)
|
||||
this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
|
||||
TypeID.prototype.name = "";
|
||||
TypeID.prototype.groupID = 0;
|
||||
TypeID.prototype.categoryID = 0;
|
||||
TypeID.prototype.published = false;
|
||||
TypeID.prototype.factionID = undefined;
|
||||
TypeID.prototype.marketGroupID = undefined;
|
||||
TypeID.prototype.metaGroupID = undefined;
|
||||
TypeID.prototype.capacity = undefined;
|
||||
TypeID.prototype.mass = undefined;
|
||||
TypeID.prototype.radius = undefined;
|
||||
TypeID.prototype.volume = undefined;
|
||||
Type.prototype.name = "";
|
||||
Type.prototype.groupID = 0;
|
||||
Type.prototype.categoryID = 0;
|
||||
Type.prototype.published = false;
|
||||
Type.prototype.factionID = undefined;
|
||||
Type.prototype.marketGroupID = undefined;
|
||||
Type.prototype.metaGroupID = undefined;
|
||||
Type.prototype.capacity = undefined;
|
||||
Type.prototype.mass = undefined;
|
||||
Type.prototype.radius = undefined;
|
||||
Type.prototype.volume = undefined;
|
||||
|
||||
TypeID.decode = function decode(r, l) {
|
||||
Type.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader))
|
||||
r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.TypeIDs.TypeID();
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.Types.Type();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
@@ -338,15 +338,15 @@ export const esf = $root.esf = (() => {
|
||||
return m;
|
||||
};
|
||||
|
||||
return TypeID;
|
||||
return Type;
|
||||
})();
|
||||
|
||||
return TypeIDs;
|
||||
return Types;
|
||||
})();
|
||||
|
||||
esf.GroupIDs = (function() {
|
||||
esf.Groups = (function() {
|
||||
|
||||
function GroupIDs(p) {
|
||||
function Groups(p) {
|
||||
this.entries = {};
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
@@ -354,12 +354,12 @@ export const esf = $root.esf = (() => {
|
||||
this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
|
||||
GroupIDs.prototype.entries = emptyObject;
|
||||
Groups.prototype.entries = emptyObject;
|
||||
|
||||
GroupIDs.decode = async function decode(r, l) {
|
||||
Groups.decode = async function decode(r, l) {
|
||||
if (!(r instanceof $Reader))
|
||||
r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.GroupIDs(), k, value;
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.Groups(), k, value;
|
||||
while (r.pos < c) {
|
||||
if (r.need_data()) {
|
||||
await r.fetch_data();
|
||||
@@ -381,7 +381,7 @@ export const esf = $root.esf = (() => {
|
||||
k = r.int32();
|
||||
break;
|
||||
case 2:
|
||||
value = $root.esf.GroupIDs.GroupID.decode(r, r.uint32());
|
||||
value = $root.esf.Groups.Group.decode(r, r.uint32());
|
||||
break;
|
||||
default:
|
||||
r.skipType(tag2 & 7);
|
||||
@@ -399,23 +399,23 @@ export const esf = $root.esf = (() => {
|
||||
return m;
|
||||
};
|
||||
|
||||
GroupIDs.GroupID = (function() {
|
||||
Groups.Group = (function() {
|
||||
|
||||
function GroupID(p) {
|
||||
function Group(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null)
|
||||
this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
|
||||
GroupID.prototype.name = "";
|
||||
GroupID.prototype.categoryID = 0;
|
||||
GroupID.prototype.published = false;
|
||||
Group.prototype.name = "";
|
||||
Group.prototype.categoryID = 0;
|
||||
Group.prototype.published = false;
|
||||
|
||||
GroupID.decode = function decode(r, l) {
|
||||
Group.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader))
|
||||
r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.GroupIDs.GroupID();
|
||||
var c = l === undefined ? r.len : r.pos + l, m = new $root.esf.Groups.Group();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
@@ -445,10 +445,10 @@ export const esf = $root.esf = (() => {
|
||||
return m;
|
||||
};
|
||||
|
||||
return GroupID;
|
||||
return Group;
|
||||
})();
|
||||
|
||||
return GroupIDs;
|
||||
return Groups;
|
||||
})();
|
||||
|
||||
esf.MarketGroups = (function() {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { useEveData, EveDataProvider } from "./EveDataProvider";
|
||||
export type { EveData } from "./EveDataProvider";
|
||||
export type { DogmaAttribute, DogmaEffect, TypeDogmaAttribute, TypeDogmaEffect, TypeID } from "./DataTypes";
|
||||
export type { DogmaAttribute, DogmaEffect, TypeDogmaAttribute, TypeDogmaEffect, Type } from "./DataTypes";
|
||||
|
||||
@@ -153,7 +153,7 @@ export const FitManagerProvider = (props: FitManagerProps) => {
|
||||
eveData.typeDogma[typeId]?.dogmaAttributes.find(
|
||||
(attr) => attr.attributeID === eveData.attributeMapping?.chargeSize,
|
||||
)?.value ?? -1;
|
||||
const groupID = eveData.typeIDs[typeId]?.groupID ?? -1;
|
||||
const groupID = eveData.types[typeId]?.groupID ?? -1;
|
||||
|
||||
const newModules = [];
|
||||
for (let module of oldFit.modules) {
|
||||
@@ -319,7 +319,7 @@ export const FitManagerProvider = (props: FitManagerProps) => {
|
||||
eveData.typeDogma[typeId]?.dogmaAttributes.find(
|
||||
(attr) => attr.attributeID === eveData.attributeMapping?.chargeSize,
|
||||
)?.value ?? -1;
|
||||
const groupID = eveData.typeIDs[typeId]?.groupID ?? -1;
|
||||
const groupID = eveData.types[typeId]?.groupID ?? -1;
|
||||
|
||||
setFit((oldFit: EsfFit | null): EsfFit | null => {
|
||||
if (oldFit === null) return null;
|
||||
|
||||
@@ -77,7 +77,7 @@ const CalculateSlots = (eveData: EveData, statistics: Statistics) => {
|
||||
const CalculateCargoBay = (eveData: EveData, fit: EsfFit): number => {
|
||||
/* Calculate the volume of all cargo. */
|
||||
const cargoVolume = fit.cargo.reduce((acc, cargo) => {
|
||||
const type = eveData.typeIDs[cargo.typeId];
|
||||
const type = eveData.types[cargo.typeId];
|
||||
if (type === undefined) return acc;
|
||||
|
||||
return acc + (type.volume ?? 0) * cargo.quantity;
|
||||
|
||||
Reference in New Issue
Block a user