EVEShip.fit 为 Javascript 设计的多格玛引擎
这个库精确地计算出一个EVE Online ship fit的统计数据.
投入是EVE Online公司提供的几个数据文件,以及一个适合的船. 输出是舰只的所有道克玛属性,其物品和人物.
引擎以 Rust 写成,并以 Web Assembly 运行,所以一切都在浏览器中计算;不需要服务器.
安装
@eveshipfit/sde 船舶 sde.dat 联合国 dist 文件夹; 服务或捆绑文件.
npm install @eveshipfit/dogma-engine @eveshipfit/sde
软件包是一个ES模块,包含TypeScript类型,它随处运行:在捆绑器下
(Vite,webpack,.),来自CDN,或平地 <script type="module">。 。 。 .
使用量
默认导出会加载 Web Assembly, 在调用其他函数前必须等待一次 .
import wasmInit, {
load_sde,
load_eft,
save_eft,
load_esi_fitting,
save_esi_fitting,
load_dna,
post_load,
load_killmail,
load_link,
calculate,
beacon,
} from "@eveshipfit/dogma-engine";
await wasmInit();
const sde = await fetch("/sde.dat").then((response) => response.arrayBuffer());
const buildNumber = load_sde(new Uint8Array(sde));
const fit = {
ship: { type_id: 587 },
items: [{ type_id: 2873, slot: { type: "high", index: 0 }, state: "active", charge: { type_id: 185 } }],
character: { skills: { 3300: 5 } },
};
const calculation = calculate(fit);
/* Or if you want to know the source of the effects: */
const withSources = calculate(fit, { sources: true });
/* Or if you have a beacon in space (like wormhole effects): */
const withBeacon = calculate({ ...fit, incoming: beacon(beaconTypeId) });
/* Or if you have an EFT, the text format EVE copies a fit to the clipboard in: */
const imported = calculate(load_eft("[Rifter, My Rifter]\n200mm AutoCannon I"));
/* And to write a fit back out as EFT: */
const eft = save_eft(fit);
/* Or if you have a fitting a character saved in game, as ESI returns it (and the other way around): */
const fromEsi = load_esi_fitting(fitting);
const toEsi = save_esi_fitting(fit);
/* Or if you have DNA, the fits EVE links to in chat, with or without its `fitting:` prefix: */
const fromDna = load_dna(dna);
/* EFT, ESI and DNA have no states; with the skills set, this sets the ones EVE gives an imported fit: */
const settled = post_load({ ...fromEsi, character: { skills } });
/* Or if you have a killmail, as ESI returns it, for the fit of the ship that died: */
const fromKillmail = load_killmail(killmail);
/* Or if you have an EVEShip.fit link, `<version>:<payload>`, with the payload gunzipped and unbase64'd: */
const fromLink = load_link(version, payload);
/* What EVE would not let you fly, in `violations` of the calculation: */
const validated = calculate(fit, { validate: true });
load_sde 只能调用一次.
EFT 导入符合英文名称 sde.dat。 。 。 .
同时匹配 EVE 支持的其他语言, 手 names.dat (另见 @eveshipfit/sde改为: load_names 同样的方式,之后 load_sde。 。 。 .
匹配和计算是平面对象,由包含的TypeScript类型描述. 每一个字段意味着什么 投入和产出。 。 。 .
再来
引擎是如何工作的,属性 EVEShip.fit 添加及其验证的适配规则都包含在 主要仓库。 。 。 .