@eveshipfit/dogma-engine 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,6 +74,7 @@ All identifiers are those from the SDE.
74
74
 
75
75
  - `sources` (optional, default false): report per attribute what its value was calculated from.
76
76
  Leave it off unless you show it; it makes the calculation several times bigger.
77
+ - `validate` (optional, default false): also report the fitting rules the fit breaks, as `violations`.
77
78
 
78
79
  ### Calculation
79
80
 
@@ -85,6 +86,8 @@ All identifiers are those from the SDE.
85
86
  - `id`: which buff, as `dbuffCollections` in the SDE numbers them.
86
87
  - `value`: how strong it is, in whatever the buff's operation reads.
87
88
  - `outgoing`: what the fit hands to other fits, in the shape `incoming` takes.
89
+ - `violations`: the fitting rules the fit breaks; only with the `validate` option.
90
+ Absent means they were not looked for, an empty list means none were broken.
88
91
 
89
92
  Each result has:
90
93
 
@@ -114,9 +117,12 @@ What additional attributes exist are defined in [EVEShipFit/sde-patched](https:/
114
117
 
115
118
  ## Validation
116
119
 
117
- `validate()` checks if the fit violates any rules that would prevent you from flying it in-game.
118
- It returns the violations, grouped by the kind of rule and, within a kind, in the order of `items`.
119
- An empty list means the fit breaks no rules.
120
+ The `validate` option checks if the fit violates any rules that would prevent you from flying it in-game.
121
+ The calculation then carries `violations`, grouped by the kind of rule and, within a kind, in the order of `items`.
122
+ An empty list means the fit breaks no rules; absent means the option was off.
123
+
124
+ Every rule reads the values after skills and modules changed them, so validation is part of `calculate()`
125
+ rather than a call of its own; asking for both costs one calculation, not two.
120
126
 
121
127
  Each violation has:
122
128
 
@@ -162,7 +168,7 @@ cargo add esf-dogma-engine esf-data
162
168
 
163
169
  ```rust
164
170
  use esf_data::{InfoSde, Sde};
165
- use esf_dogma_engine::{Fit, Options, beacon, calculate, validate};
171
+ use esf_dogma_engine::{Fit, Options, beacon, calculate};
166
172
 
167
173
  let bytes = std::fs::read("sde.dat")?;
168
174
  let sde = Sde::new(&bytes)?;
@@ -189,8 +195,8 @@ let with_sources = calculate(&info, &fit, &Options { sources: true, ..Default::d
189
195
  // Or if you have a beacon in space (like wormhole effects):
190
196
  let with_beacon = calculate(&info, &Fit { incoming: beacon(&info, beacon_type_id), ..fit }, &Options::default());
191
197
 
192
- // What EVE would not let you fly:
193
- let violations = validate(&info, &fit, &calculation);
198
+ // What EVE would not let you fly, in `violations` of the calculation:
199
+ let validated = calculate(&info, &fit, &Options { validate: true, ..Default::default() });
194
200
  ```
195
201
 
196
202
  ### Javascript (WebAssembly)
@@ -213,7 +219,6 @@ import wasmInit, {
213
219
  load_eft,
214
220
  save_eft,
215
221
  calculate,
216
- validate,
217
222
  beacon,
218
223
  } from "@eveshipfit/dogma-engine";
219
224
 
@@ -237,8 +242,8 @@ const imported = calculate(load_eft("[Rifter, My Rifter]\n200mm AutoCannon I"));
237
242
  /* And to write a fit back out as EFT: */
238
243
  const eft = save_eft(fit);
239
244
 
240
- /* What EVE would not let you fly; it calculates the fit itself: */
241
- const violations = validate(fit);
245
+ /* What EVE would not let you fly, in `violations` of the calculation: */
246
+ const validated = calculate(fit, { validate: true });
242
247
  ```
243
248
 
244
249
  ### Python
@@ -280,8 +285,8 @@ imported = dogma.calculate(dogma.load_eft("[Rifter, My Rifter]\n200mm AutoCannon
280
285
  # And to write a fit back out as EFT:
281
286
  eft = dogma.save_eft(fit)
282
287
 
283
- # What EVE would not let you fly; it calculates the fit itself:
284
- violations = dogma.validate(fit)
288
+ # What EVE would not let you fly, in `violations` of the calculation:
289
+ validated = dogma.calculate(fit, {"validate": True})
285
290
  ```
286
291
 
287
292
  Fits and calculations are plain dicts, typed with `TypedDict` in `esf_dogma_engine.types`.
@@ -340,6 +340,10 @@ export interface Calculation {
340
340
  * All outgoing projections (effects and buffs).
341
341
  */
342
342
  outgoing?: Projection;
343
+ /**
344
+ * The fitting rules the fit breaks; only with `Options::validate`.
345
+ */
346
+ violations?: Violation[];
343
347
  }
344
348
 
345
349
  /**
@@ -374,6 +378,10 @@ export interface Options {
374
378
  * Report per attribute the modifiers its value was calculated from.
375
379
  */
376
380
  sources?: boolean;
381
+ /**
382
+ * Report the fitting rules the fit breaks.
383
+ */
384
+ validate?: boolean;
377
385
  }
378
386
 
379
387
  /**
@@ -462,12 +470,6 @@ export function save_eft(fit: Fit): string;
462
470
 
463
471
  export function set_panic_hook(): void;
464
472
 
465
- /**
466
- * Report the fitting rules the fit breaks. Calculates the fit itself, as
467
- * every rule reads the values after skills and modules changed them.
468
- */
469
- export function validate(fit: Fit): Violation[];
470
-
471
473
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
472
474
 
473
475
  export interface InitOutput {
@@ -479,7 +481,6 @@ export interface InitOutput {
479
481
  readonly load_sde: (a: number, b: number) => [number, number, number];
480
482
  readonly save_eft: (a: any) => [number, number, number, number];
481
483
  readonly set_panic_hook: () => void;
482
- readonly validate: (a: any) => [number, number, number];
483
484
  readonly __wbindgen_malloc: (a: number, b: number) => number;
484
485
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
485
486
  readonly __wbindgen_exn_store: (a: number) => void;
@@ -103,20 +103,6 @@ export function save_eft(fit) {
103
103
  export function set_panic_hook() {
104
104
  wasm.set_panic_hook();
105
105
  }
106
-
107
- /**
108
- * Report the fitting rules the fit breaks. Calculates the fit itself, as
109
- * every rule reads the values after skills and modules changed them.
110
- * @param {Fit} fit
111
- * @returns {Violation[]}
112
- */
113
- export function validate(fit) {
114
- const ret = wasm.validate(fit);
115
- if (ret[2]) {
116
- throw takeFromExternrefTable0(ret[1]);
117
- }
118
- return takeFromExternrefTable0(ret[0]);
119
- }
120
106
  function __wbg_get_imports() {
121
107
  const import0 = {
122
108
  __proto__: null,
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "EVEShipFit Team <info@eveship.fit>"
6
6
  ],
7
7
  "description": "Library to calculate statistics for EVE Online ship fits",
8
- "version": "12.0.0",
8
+ "version": "13.0.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",