chore: ShipSnapshotSlotsType was not consistent in its type (#118)
This commit is contained in:
@@ -4,7 +4,7 @@ import { EveDataContext } from "../EveDataProvider";
|
||||
import { ShipSnapshotContext, ShipSnapshotSlotsType } from "../ShipSnapshotProvider";
|
||||
|
||||
/** Mapping between slot types and ESI flags (for first slot in the type). */
|
||||
const esiFlagMapping: Record<ShipSnapshotSlotsType | "droneBay", number[]> = {
|
||||
const esiFlagMapping: Record<ShipSnapshotSlotsType, number[]> = {
|
||||
lowslot: [11, 12, 13, 14, 15, 16, 17, 18],
|
||||
medslot: [19, 20, 21, 22, 23, 24, 25, 26],
|
||||
hislot: [27, 28, 29, 30, 31, 32, 33, 34],
|
||||
@@ -14,7 +14,7 @@ const esiFlagMapping: Record<ShipSnapshotSlotsType | "droneBay", number[]> = {
|
||||
};
|
||||
|
||||
/** Mapping between slot-type and the EFT string name. */
|
||||
const slotToEft: Record<ShipSnapshotSlotsType | "droneBay", string> = {
|
||||
const slotToEft: Record<ShipSnapshotSlotsType, string> = {
|
||||
lowslot: "Low Slot",
|
||||
medslot: "Mid Slot",
|
||||
hislot: "High Slot",
|
||||
|
||||
@@ -20,7 +20,7 @@ interface ListingItem {
|
||||
name: string;
|
||||
meta: number;
|
||||
typeId: number;
|
||||
slotType: ShipSnapshotSlotsType | "dronebay" | "charge";
|
||||
slotType: ShipSnapshotSlotsType | "charge";
|
||||
}
|
||||
|
||||
interface ListingGroup {
|
||||
@@ -202,7 +202,7 @@ export const HardwareListing = () => {
|
||||
if (module.marketGroupID === undefined) continue;
|
||||
if (!module.published) continue;
|
||||
|
||||
let slotType: ShipSnapshotSlotsType | "dronebay" | "charge" | undefined;
|
||||
let slotType: ShipSnapshotSlotsType | "charge" | undefined;
|
||||
if (module.categoryID !== 8) {
|
||||
slotType = eveData.typeDogma?.[typeId]?.dogmaEffects
|
||||
.map((effect) => {
|
||||
@@ -221,7 +221,7 @@ export const HardwareListing = () => {
|
||||
})
|
||||
.filter((slot) => slot !== undefined)[0];
|
||||
if (module.categoryID === 18) {
|
||||
slotType = "dronebay";
|
||||
slotType = "droneBay";
|
||||
}
|
||||
|
||||
if (slotType === undefined) continue;
|
||||
|
||||
@@ -53,7 +53,7 @@ interface ShipSnapshotSlots {
|
||||
turret: number;
|
||||
}
|
||||
|
||||
export type ShipSnapshotSlotsType = keyof ShipSnapshotSlots;
|
||||
export type ShipSnapshotSlotsType = "hislot" | "medslot" | "lowslot" | "subsystem" | "rig" | "droneBay";
|
||||
|
||||
interface ShipSnapshot {
|
||||
loaded?: boolean;
|
||||
@@ -70,7 +70,7 @@ interface ShipSnapshot {
|
||||
currentFit?: EsiFit;
|
||||
currentSkills?: Record<string, number>;
|
||||
|
||||
addModule: (typeId: number, slot: ShipSnapshotSlotsType | "dronebay") => void;
|
||||
addModule: (typeId: number, slot: ShipSnapshotSlotsType) => void;
|
||||
removeModule: (flag: number) => void;
|
||||
addCharge: (chargeTypeId: number) => void;
|
||||
removeCharge: (flag: number) => void;
|
||||
@@ -113,8 +113,7 @@ const slotStart: Record<ShipSnapshotSlotsType, number> = {
|
||||
lowslot: 11,
|
||||
subsystem: 125,
|
||||
rig: 92,
|
||||
launcher: 27,
|
||||
turret: 27,
|
||||
droneBay: 87,
|
||||
};
|
||||
|
||||
export interface ShipSnapshotProps {
|
||||
@@ -191,14 +190,14 @@ export const ShipSnapshotProvider = (props: ShipSnapshotProps) => {
|
||||
}, []);
|
||||
|
||||
const addModule = React.useCallback(
|
||||
(typeId: number, slot: ShipSnapshotSlotsType | "dronebay") => {
|
||||
(typeId: number, slot: ShipSnapshotSlotsType) => {
|
||||
setCurrentFit((oldFit: EsiFit | undefined) => {
|
||||
if (oldFit === undefined) return undefined;
|
||||
|
||||
let flag = 0;
|
||||
|
||||
/* Find the first free slot for that slot-type. */
|
||||
if (slot !== "dronebay") {
|
||||
if (slot !== "droneBay") {
|
||||
for (let i = slotStart[slot]; i < slotStart[slot] + shipSnapshot.slots[slot]; i++) {
|
||||
if (oldFit.items.find((item) => item.flag === i) !== undefined) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user