@eveshipfit/fitting
v2.2.1
Published
EVE Online ship fits that recalculate themselves
Downloads
1,345
Readme
@eveshipfit/fitting
EVE Online ship fits that recalculate themselves, on top of
@eveshipfit/dogma-engine.
Part of EVEShip.fit.
Install
npm install @eveshipfit/fitting @eveshipfit/dogma-engine @eveshipfit/esi @eveshipfit/sde-loader @eveshipfit/sdeUsage
The examples use Vite's ?url imports to get the URL of a data file.
import wasmUrl from "@eveshipfit/dogma-engine/esf_dogma_engine_bg.wasm?url";
import { createEngine } from "@eveshipfit/fitting";
import sdeUrl from "@eveshipfit/sde/dist/sde.dat?url";
import { loadSde } from "@eveshipfit/sde-loader";
const engine = await createEngine(await loadSde({ url: sdeUrl }), { wasm: wasmUrl });
const fit = engine.createFit({ ship: 587 }); // a Rifter
fit.fit(engine.sde.typeByName("200mm AutoCannon II")!.id); // first free high slot
fit.fit(engine.sde.typeByName("EMP S")!.id); // loaded into every gun that takes it
fit.move(0, { type: "high", index: 2 }); // to another slot, swapping with what is there
const { stats } = fit.getSnapshot();
stats.ship.get("cpuLoad");
stats.slots.high; // { used: 1, total: 3 }
stats.violations; // the fitting rules the fit breaks
fit.undo();The engine can hold only one SDE per page; createEngine with another one throws.
A fit is flown by a character with every skill at V, unless you pass another to createFit or setCharacter.
loadLink reads the fit of an EVEShip.fit link, or of dna:<dna>. A killmail link needs an Esi of
@eveshipfit/esi in createEngine's esi option.
React
subscribe and getSnapshot are bound, so a store goes straight into useSyncExternalStore:
const { fit, stats } = useSyncExternalStore(store.subscribe, store.getSnapshot);Every change gives a new snapshot; old ones never change.
Previews
preview shows what an edit would do, without doing it:
const { before, after } = fit.preview((draft) => draft.fit(typeId));
after.stats.ship.get("cpuLoad")! - before.stats.ship.get("cpuLoad")!;Rules
placementOf, canFit, acceptsCharge and chargesFor say where a type goes, whether a module fits a hull, and
which charges go in a module; for example to filter a market browser. droneRoom says how many more drones of a type
can be active. fighterKind, squadronSize and tubeTakes say which tubes a fighter takes, how big its squadron is,
and whether a tube can launch it. modesOf gives the modes of a ship, like a tactical destroyer's; a FitStore keeps
its fit in one of them, which setMode switches.
missingSkills says which skills a character lacks to use some types, with the skills those skills need;
typesInUse gives the types of a fit that need them.
fitPrice says what a fit costs at a price per type, without implants and boosters.
License
MIT
