@dicelette/core 1.23.1 → 1.24.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/dist/index.d.mts CHANGED
@@ -1,66 +1,7 @@
1
1
  import { Engine, Random } from 'random-js';
2
+ import { DiceRoll } from '@dice-roller/rpg-dice-roller';
2
3
  import { z } from 'zod';
3
4
 
4
- /**
5
- * Allow to replace the compare part of a dice and use the critical customized one
6
- * @example
7
- * dice = "1d20=20";
8
- * custom critical {sign: ">", value: "$/2"}
9
- * Random stats = 6
10
- * result = "1d20>3"
11
- */
12
- declare function createCriticalCustom(dice: string, customCritical: CustomCritical, template: StatisticalTemplate, engine?: Engine | null): string;
13
- /**
14
- * Parse the string provided and turn it as a readable dice for dice parser
15
- * @param dice {string}
16
- * @param engine
17
- * @param pity
18
- */
19
- declare function roll(dice: string, engine?: Engine | null, pity?: boolean): Resultat | undefined;
20
- /**
21
- * Evaluate a formula and replace "^" by "**" if any
22
- * @param {Sign} sign
23
- * @param {number} value
24
- * @param {number} total
25
- * @returns
26
- */
27
- declare function calculator(sign: Sign, value: number, total: number): number;
28
-
29
- declare class DiceTypeError extends Error {
30
- readonly dice: string;
31
- readonly cause: string | undefined;
32
- readonly method: unknown;
33
- constructor(dice: string, cause?: string, method?: unknown);
34
- }
35
- declare class FormulaError extends Error {
36
- readonly formula: string;
37
- readonly cause: string | undefined;
38
- readonly method: unknown;
39
- constructor(formula: string, cause?: string, method?: unknown);
40
- }
41
- declare class MaxGreater extends Error {
42
- readonly name: string;
43
- readonly value: number;
44
- readonly max: number;
45
- constructor(value: number, max: number);
46
- }
47
- declare class EmptyObjectError extends Error {
48
- readonly name: string;
49
- constructor();
50
- }
51
- declare class TooManyDice extends Error {
52
- readonly name: string;
53
- constructor();
54
- }
55
- declare class TooManyStats extends Error {
56
- readonly name: string;
57
- constructor();
58
- }
59
- declare class NoStatisticsError extends Error {
60
- readonly name: string;
61
- constructor();
62
- }
63
-
64
5
  interface Resultat {
65
6
  /**
66
7
  * Original dice throw
@@ -87,6 +28,7 @@ interface Resultat {
87
28
  */
88
29
  total?: number;
89
30
  pityLogs?: number;
31
+ trivial?: boolean;
90
32
  }
91
33
  interface Compare {
92
34
  /**
@@ -240,6 +182,138 @@ interface CustomCritical {
240
182
  */
241
183
  affectSkill?: boolean;
242
184
  }
185
+ declare enum SortOrder {
186
+ Ascending = "sa",
187
+ Descending = "sd",
188
+ None = "none"
189
+ }
190
+
191
+ /**
192
+ * Evaluate a formula and replace "^" by "**" if any
193
+ * @param {Sign} sign
194
+ * @param {number} value
195
+ * @param {number} total
196
+ * @returns
197
+ */
198
+ declare function calculator(sign: Sign, value: number, total: number): number;
199
+
200
+ /**
201
+ * Check if a comparison is trivial (always true or always false)
202
+ * Uses the existing canComparisonSucceed logic and checks both success and failure conditions
203
+ * @param maxValue Maximum possible value from the dice roll
204
+ * @param minValue Minimum possible value from the dice roll
205
+ * @param compare The comparison object
206
+ * @returns true if the comparison is trivial (always true or always false)
207
+ */
208
+ declare function isTrivialComparison(maxValue: number, minValue: number, compare: ComparedValue): boolean;
209
+ /**
210
+ * Check if a comparison can theoretically fail given roll bounds
211
+ * @param maxRollValue Maximum possible roll value
212
+ * @param compare The comparison object
213
+ * @param minRollValue Minimum possible roll value (defaults to 1)
214
+ * @returns true if the comparison can fail at least once
215
+ */
216
+ declare function canComparisonFail(maxRollValue: number, compare: ComparedValue, minRollValue?: number): boolean;
217
+ declare function getCompare(dice: string, compareRegex: RegExpMatchArray, engine?: Engine | null, pity?: boolean): {
218
+ dice: string;
219
+ compare: ComparedValue | undefined;
220
+ };
221
+ /**
222
+ * Check if a comparison can theoretically succeed given a maximum roll value
223
+ * @example
224
+ * canComparisonSucceed(10, { sign: ">=", value: 15 }) => false (impossible to roll >= 15 with 1d10)
225
+ * canComparisonSucceed(20, { sign: ">=", value: 15 }) => true (possible to roll >= 15 with 1d20)
226
+ */
227
+ declare function canComparisonSucceed(maxRollValue: number, compare: ComparedValue, minRollValue?: number): boolean;
228
+
229
+ type ExplodingSuccess = {
230
+ dice: string;
231
+ originalDice: string;
232
+ sign: Compare["sign"];
233
+ value: number;
234
+ normalizedSegment: string;
235
+ originalSegment: string;
236
+ };
237
+ declare const EXPLODING_SUCCESS_REGEX: RegExp;
238
+ declare function normalizeExplodingSuccess(dice: string): ExplodingSuccess | undefined;
239
+ declare function countExplodingSuccesses(diceRoll: DiceRoll | DiceRoll[], sign: Compare["sign"], value: number): number;
240
+
241
+ declare function getModifier(dice: string): Modifier | undefined;
242
+ declare function extractValuesFromOutput(output: string): number[];
243
+ declare function getRollBounds(dice: string, engine?: Engine | null): {
244
+ min: number;
245
+ max: number;
246
+ } | undefined;
247
+
248
+ declare function replaceUnwantedText(dice: string): string;
249
+ declare function fixParenthesis(dice: string): string;
250
+ declare function replaceText(element: string, total: number, dice: string): {
251
+ formule: string;
252
+ diceAll: string;
253
+ };
254
+ declare function formatComment(dice: string): string;
255
+
256
+ declare function matchComparison(sign: Compare["sign"], val: number, value: number): boolean;
257
+ declare function inverseSign(sign: "<" | ">" | ">=" | "<=" | "=" | "!=" | "=="): "<" | ">" | ">=" | "<=" | "=" | "!=" | "==";
258
+ declare function compareSignFormule(toRoll: string, compareRegex: RegExpMatchArray, element: string, diceResult: Resultat, engine?: Engine | null, pity?: boolean, rollBounds?: {
259
+ min: number;
260
+ max: number;
261
+ }): {
262
+ dice: string;
263
+ results: string;
264
+ compare?: Compare;
265
+ trivial: boolean;
266
+ };
267
+
268
+ /**
269
+ * Utility function that allow to get the id of an engine
270
+ * @param engine {unknown} Engine to identify
271
+ * @returns {string} Id of the engine or "unknown"
272
+ * @private
273
+ */
274
+ declare function getEngineId(engine: unknown): string;
275
+ /**
276
+ * Utility function to get the engine from its name
277
+ * @param engine {"nativeMath" | "browserCrypto" | "nodeCrypto"} The engine name
278
+ * @returns {Engine} The engine
279
+ * @public
280
+ */
281
+ declare function getEngine(engine: "nativeMath" | "browserCrypto" | "nodeCrypto"): Engine;
282
+
283
+ declare class DiceTypeError extends Error {
284
+ readonly dice: string;
285
+ readonly cause: string | undefined;
286
+ readonly method: unknown;
287
+ constructor(dice: string, cause?: string, method?: unknown);
288
+ }
289
+ declare class FormulaError extends Error {
290
+ readonly formula: string;
291
+ readonly cause: string | undefined;
292
+ readonly method: unknown;
293
+ constructor(formula: string, cause?: string, method?: unknown);
294
+ }
295
+ declare class MaxGreater extends Error {
296
+ readonly name: string;
297
+ readonly value: number;
298
+ readonly max: number;
299
+ constructor(value: number, max: number);
300
+ }
301
+ declare class EmptyObjectError extends Error {
302
+ readonly name: string;
303
+ constructor();
304
+ }
305
+ declare class TooManyDice extends Error {
306
+ readonly name: string;
307
+ constructor();
308
+ }
309
+ declare class TooManyStats extends Error {
310
+ readonly name: string;
311
+ constructor();
312
+ }
313
+ declare class NoStatisticsError extends Error {
314
+ readonly name: string;
315
+ constructor();
316
+ }
243
317
 
244
318
  declare const COMMENT_REGEX: RegExp;
245
319
  declare const SIGN_REGEX: RegExp;
@@ -297,6 +371,33 @@ declare const templateSchema: z.ZodObject<{
297
371
  damage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
298
372
  }, z.core.$strip>;
299
373
 
374
+ /**
375
+ * Parse the string provided and turn it as a readable dice for dice parser
376
+ * @param {string} dice The dice string to parse and roll
377
+ * @param {Engine|null} engine The random engine to use, default to nodeCrypto
378
+ * @param {boolean} pity Whether to enable pity system (reroll on failure) or not
379
+ * @param {boolean} sort Whether to sort the dice results or not
380
+ * @returns {Resultat|undefined} The result of the roll
381
+ */
382
+ declare function roll(dice: string, engine?: Engine | null, pity?: boolean, sort?: SortOrder): Resultat | undefined;
383
+ declare function replaceInFormula(element: string, diceResult: Resultat, compareResult: {
384
+ dice: string;
385
+ compare: Compare | undefined;
386
+ }, res: boolean, engine?: Engine | null, pity?: boolean): string;
387
+ declare function rollCompare(value: unknown, engine?: Engine | null, pity?: boolean): {
388
+ value: number;
389
+ diceResult?: undefined;
390
+ dice?: undefined;
391
+ } | {
392
+ value: any;
393
+ diceResult: string;
394
+ dice?: undefined;
395
+ } | {
396
+ dice: string;
397
+ value: number;
398
+ diceResult: string;
399
+ };
400
+
300
401
  /**
301
402
  * Escape regex string
302
403
  * @param string {string}
@@ -345,19 +446,14 @@ declare function replaceExpByRandom(dice: string, engine?: Engine | null): strin
345
446
  */
346
447
  declare function randomInt(min: number, max: number, engine?: Engine | null, rng?: Random): number;
347
448
  /**
348
- * Utility function that allow to get the id of an engine
349
- * @param engine {unknown} Engine to identify
350
- * @returns {string} Id of the engine or "unknown"
351
- * @private
352
- */
353
- declare function getEngineId(engine: unknown): string;
354
- /**
355
- * Utility function to get the engine from its name
356
- * @param engine {"nativeMath" | "browserCrypto" | "nodeCrypto"} The engine name
357
- * @returns {Engine} The engine
358
- * @public
449
+ * Allow to replace the compare part of a dice and use the critical customized one
450
+ * @example
451
+ * dice = "1d20=20";
452
+ * custom critical {sign: ">", value: "$/2"}
453
+ * Random stats = 6
454
+ * result = "1d20>3"
359
455
  */
360
- declare function getEngine(engine: "nativeMath" | "browserCrypto" | "nodeCrypto"): Engine;
456
+ declare function createCriticalCustom(dice: string, customCritical: CustomCritical, template: StatisticalTemplate, engine?: Engine | null): string;
361
457
 
362
458
  /**
363
459
  * Verify if the provided dice work with random value
@@ -425,4 +521,4 @@ declare function testStatCombinaison(template: StatisticalTemplate, engine?: Eng
425
521
  */
426
522
  declare function generateRandomStat(total?: number | undefined, max?: number, min?: number, engine?: Engine | null): number;
427
523
 
428
- export { COMMENT_REGEX, type Compare, type ComparedValue, type Critical, type CustomCritical, type CustomCriticalMap, DETECT_CRITICAL, DiceTypeError, EmptyObjectError, FormulaError, MaxGreater, type Modifier, NoStatisticsError, OPTIONAL_COMMENT, type Resultat, SIGN_REGEX, SIGN_REGEX_SPACE, SYMBOL_DICE, type Sign, type Statistic, type StatisticalSchema, type StatisticalTemplate, TooManyDice, TooManyStats, calculator, createCriticalCustom, diceRandomParse, diceTypeRandomParse, escapeRegex, evalCombinaison, evalOneCombinaison, evalStatsDice, generateRandomStat, generateStatsDice, getEngine, getEngineId, isNumber, randomInt, replaceExpByRandom, replaceFormulaInDice, roll, standardizeDice, templateSchema, testDiceRegistered, testStatCombinaison, verifyTemplateValue };
524
+ export { COMMENT_REGEX, type Compare, type ComparedValue, type Critical, type CustomCritical, type CustomCriticalMap, DETECT_CRITICAL, DiceTypeError, EXPLODING_SUCCESS_REGEX, EmptyObjectError, type ExplodingSuccess, FormulaError, MaxGreater, type Modifier, NoStatisticsError, OPTIONAL_COMMENT, type Resultat, SIGN_REGEX, SIGN_REGEX_SPACE, SYMBOL_DICE, type Sign, SortOrder, type Statistic, type StatisticalSchema, type StatisticalTemplate, TooManyDice, TooManyStats, calculator, canComparisonFail, canComparisonSucceed, compareSignFormule, countExplodingSuccesses, createCriticalCustom, diceRandomParse, diceTypeRandomParse, escapeRegex, evalCombinaison, evalOneCombinaison, evalStatsDice, extractValuesFromOutput, fixParenthesis, formatComment, generateRandomStat, generateStatsDice, getCompare, getEngine, getEngineId, getModifier, getRollBounds, inverseSign, isNumber, isTrivialComparison, matchComparison, normalizeExplodingSuccess, randomInt, replaceExpByRandom, replaceFormulaInDice, replaceInFormula, replaceText, replaceUnwantedText, roll, rollCompare, standardizeDice, templateSchema, testDiceRegistered, testStatCombinaison, verifyTemplateValue };
package/dist/index.d.ts CHANGED
@@ -1,66 +1,7 @@
1
1
  import { Engine, Random } from 'random-js';
2
+ import { DiceRoll } from '@dice-roller/rpg-dice-roller';
2
3
  import { z } from 'zod';
3
4
 
4
- /**
5
- * Allow to replace the compare part of a dice and use the critical customized one
6
- * @example
7
- * dice = "1d20=20";
8
- * custom critical {sign: ">", value: "$/2"}
9
- * Random stats = 6
10
- * result = "1d20>3"
11
- */
12
- declare function createCriticalCustom(dice: string, customCritical: CustomCritical, template: StatisticalTemplate, engine?: Engine | null): string;
13
- /**
14
- * Parse the string provided and turn it as a readable dice for dice parser
15
- * @param dice {string}
16
- * @param engine
17
- * @param pity
18
- */
19
- declare function roll(dice: string, engine?: Engine | null, pity?: boolean): Resultat | undefined;
20
- /**
21
- * Evaluate a formula and replace "^" by "**" if any
22
- * @param {Sign} sign
23
- * @param {number} value
24
- * @param {number} total
25
- * @returns
26
- */
27
- declare function calculator(sign: Sign, value: number, total: number): number;
28
-
29
- declare class DiceTypeError extends Error {
30
- readonly dice: string;
31
- readonly cause: string | undefined;
32
- readonly method: unknown;
33
- constructor(dice: string, cause?: string, method?: unknown);
34
- }
35
- declare class FormulaError extends Error {
36
- readonly formula: string;
37
- readonly cause: string | undefined;
38
- readonly method: unknown;
39
- constructor(formula: string, cause?: string, method?: unknown);
40
- }
41
- declare class MaxGreater extends Error {
42
- readonly name: string;
43
- readonly value: number;
44
- readonly max: number;
45
- constructor(value: number, max: number);
46
- }
47
- declare class EmptyObjectError extends Error {
48
- readonly name: string;
49
- constructor();
50
- }
51
- declare class TooManyDice extends Error {
52
- readonly name: string;
53
- constructor();
54
- }
55
- declare class TooManyStats extends Error {
56
- readonly name: string;
57
- constructor();
58
- }
59
- declare class NoStatisticsError extends Error {
60
- readonly name: string;
61
- constructor();
62
- }
63
-
64
5
  interface Resultat {
65
6
  /**
66
7
  * Original dice throw
@@ -87,6 +28,7 @@ interface Resultat {
87
28
  */
88
29
  total?: number;
89
30
  pityLogs?: number;
31
+ trivial?: boolean;
90
32
  }
91
33
  interface Compare {
92
34
  /**
@@ -240,6 +182,138 @@ interface CustomCritical {
240
182
  */
241
183
  affectSkill?: boolean;
242
184
  }
185
+ declare enum SortOrder {
186
+ Ascending = "sa",
187
+ Descending = "sd",
188
+ None = "none"
189
+ }
190
+
191
+ /**
192
+ * Evaluate a formula and replace "^" by "**" if any
193
+ * @param {Sign} sign
194
+ * @param {number} value
195
+ * @param {number} total
196
+ * @returns
197
+ */
198
+ declare function calculator(sign: Sign, value: number, total: number): number;
199
+
200
+ /**
201
+ * Check if a comparison is trivial (always true or always false)
202
+ * Uses the existing canComparisonSucceed logic and checks both success and failure conditions
203
+ * @param maxValue Maximum possible value from the dice roll
204
+ * @param minValue Minimum possible value from the dice roll
205
+ * @param compare The comparison object
206
+ * @returns true if the comparison is trivial (always true or always false)
207
+ */
208
+ declare function isTrivialComparison(maxValue: number, minValue: number, compare: ComparedValue): boolean;
209
+ /**
210
+ * Check if a comparison can theoretically fail given roll bounds
211
+ * @param maxRollValue Maximum possible roll value
212
+ * @param compare The comparison object
213
+ * @param minRollValue Minimum possible roll value (defaults to 1)
214
+ * @returns true if the comparison can fail at least once
215
+ */
216
+ declare function canComparisonFail(maxRollValue: number, compare: ComparedValue, minRollValue?: number): boolean;
217
+ declare function getCompare(dice: string, compareRegex: RegExpMatchArray, engine?: Engine | null, pity?: boolean): {
218
+ dice: string;
219
+ compare: ComparedValue | undefined;
220
+ };
221
+ /**
222
+ * Check if a comparison can theoretically succeed given a maximum roll value
223
+ * @example
224
+ * canComparisonSucceed(10, { sign: ">=", value: 15 }) => false (impossible to roll >= 15 with 1d10)
225
+ * canComparisonSucceed(20, { sign: ">=", value: 15 }) => true (possible to roll >= 15 with 1d20)
226
+ */
227
+ declare function canComparisonSucceed(maxRollValue: number, compare: ComparedValue, minRollValue?: number): boolean;
228
+
229
+ type ExplodingSuccess = {
230
+ dice: string;
231
+ originalDice: string;
232
+ sign: Compare["sign"];
233
+ value: number;
234
+ normalizedSegment: string;
235
+ originalSegment: string;
236
+ };
237
+ declare const EXPLODING_SUCCESS_REGEX: RegExp;
238
+ declare function normalizeExplodingSuccess(dice: string): ExplodingSuccess | undefined;
239
+ declare function countExplodingSuccesses(diceRoll: DiceRoll | DiceRoll[], sign: Compare["sign"], value: number): number;
240
+
241
+ declare function getModifier(dice: string): Modifier | undefined;
242
+ declare function extractValuesFromOutput(output: string): number[];
243
+ declare function getRollBounds(dice: string, engine?: Engine | null): {
244
+ min: number;
245
+ max: number;
246
+ } | undefined;
247
+
248
+ declare function replaceUnwantedText(dice: string): string;
249
+ declare function fixParenthesis(dice: string): string;
250
+ declare function replaceText(element: string, total: number, dice: string): {
251
+ formule: string;
252
+ diceAll: string;
253
+ };
254
+ declare function formatComment(dice: string): string;
255
+
256
+ declare function matchComparison(sign: Compare["sign"], val: number, value: number): boolean;
257
+ declare function inverseSign(sign: "<" | ">" | ">=" | "<=" | "=" | "!=" | "=="): "<" | ">" | ">=" | "<=" | "=" | "!=" | "==";
258
+ declare function compareSignFormule(toRoll: string, compareRegex: RegExpMatchArray, element: string, diceResult: Resultat, engine?: Engine | null, pity?: boolean, rollBounds?: {
259
+ min: number;
260
+ max: number;
261
+ }): {
262
+ dice: string;
263
+ results: string;
264
+ compare?: Compare;
265
+ trivial: boolean;
266
+ };
267
+
268
+ /**
269
+ * Utility function that allow to get the id of an engine
270
+ * @param engine {unknown} Engine to identify
271
+ * @returns {string} Id of the engine or "unknown"
272
+ * @private
273
+ */
274
+ declare function getEngineId(engine: unknown): string;
275
+ /**
276
+ * Utility function to get the engine from its name
277
+ * @param engine {"nativeMath" | "browserCrypto" | "nodeCrypto"} The engine name
278
+ * @returns {Engine} The engine
279
+ * @public
280
+ */
281
+ declare function getEngine(engine: "nativeMath" | "browserCrypto" | "nodeCrypto"): Engine;
282
+
283
+ declare class DiceTypeError extends Error {
284
+ readonly dice: string;
285
+ readonly cause: string | undefined;
286
+ readonly method: unknown;
287
+ constructor(dice: string, cause?: string, method?: unknown);
288
+ }
289
+ declare class FormulaError extends Error {
290
+ readonly formula: string;
291
+ readonly cause: string | undefined;
292
+ readonly method: unknown;
293
+ constructor(formula: string, cause?: string, method?: unknown);
294
+ }
295
+ declare class MaxGreater extends Error {
296
+ readonly name: string;
297
+ readonly value: number;
298
+ readonly max: number;
299
+ constructor(value: number, max: number);
300
+ }
301
+ declare class EmptyObjectError extends Error {
302
+ readonly name: string;
303
+ constructor();
304
+ }
305
+ declare class TooManyDice extends Error {
306
+ readonly name: string;
307
+ constructor();
308
+ }
309
+ declare class TooManyStats extends Error {
310
+ readonly name: string;
311
+ constructor();
312
+ }
313
+ declare class NoStatisticsError extends Error {
314
+ readonly name: string;
315
+ constructor();
316
+ }
243
317
 
244
318
  declare const COMMENT_REGEX: RegExp;
245
319
  declare const SIGN_REGEX: RegExp;
@@ -297,6 +371,33 @@ declare const templateSchema: z.ZodObject<{
297
371
  damage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
298
372
  }, z.core.$strip>;
299
373
 
374
+ /**
375
+ * Parse the string provided and turn it as a readable dice for dice parser
376
+ * @param {string} dice The dice string to parse and roll
377
+ * @param {Engine|null} engine The random engine to use, default to nodeCrypto
378
+ * @param {boolean} pity Whether to enable pity system (reroll on failure) or not
379
+ * @param {boolean} sort Whether to sort the dice results or not
380
+ * @returns {Resultat|undefined} The result of the roll
381
+ */
382
+ declare function roll(dice: string, engine?: Engine | null, pity?: boolean, sort?: SortOrder): Resultat | undefined;
383
+ declare function replaceInFormula(element: string, diceResult: Resultat, compareResult: {
384
+ dice: string;
385
+ compare: Compare | undefined;
386
+ }, res: boolean, engine?: Engine | null, pity?: boolean): string;
387
+ declare function rollCompare(value: unknown, engine?: Engine | null, pity?: boolean): {
388
+ value: number;
389
+ diceResult?: undefined;
390
+ dice?: undefined;
391
+ } | {
392
+ value: any;
393
+ diceResult: string;
394
+ dice?: undefined;
395
+ } | {
396
+ dice: string;
397
+ value: number;
398
+ diceResult: string;
399
+ };
400
+
300
401
  /**
301
402
  * Escape regex string
302
403
  * @param string {string}
@@ -345,19 +446,14 @@ declare function replaceExpByRandom(dice: string, engine?: Engine | null): strin
345
446
  */
346
447
  declare function randomInt(min: number, max: number, engine?: Engine | null, rng?: Random): number;
347
448
  /**
348
- * Utility function that allow to get the id of an engine
349
- * @param engine {unknown} Engine to identify
350
- * @returns {string} Id of the engine or "unknown"
351
- * @private
352
- */
353
- declare function getEngineId(engine: unknown): string;
354
- /**
355
- * Utility function to get the engine from its name
356
- * @param engine {"nativeMath" | "browserCrypto" | "nodeCrypto"} The engine name
357
- * @returns {Engine} The engine
358
- * @public
449
+ * Allow to replace the compare part of a dice and use the critical customized one
450
+ * @example
451
+ * dice = "1d20=20";
452
+ * custom critical {sign: ">", value: "$/2"}
453
+ * Random stats = 6
454
+ * result = "1d20>3"
359
455
  */
360
- declare function getEngine(engine: "nativeMath" | "browserCrypto" | "nodeCrypto"): Engine;
456
+ declare function createCriticalCustom(dice: string, customCritical: CustomCritical, template: StatisticalTemplate, engine?: Engine | null): string;
361
457
 
362
458
  /**
363
459
  * Verify if the provided dice work with random value
@@ -425,4 +521,4 @@ declare function testStatCombinaison(template: StatisticalTemplate, engine?: Eng
425
521
  */
426
522
  declare function generateRandomStat(total?: number | undefined, max?: number, min?: number, engine?: Engine | null): number;
427
523
 
428
- export { COMMENT_REGEX, type Compare, type ComparedValue, type Critical, type CustomCritical, type CustomCriticalMap, DETECT_CRITICAL, DiceTypeError, EmptyObjectError, FormulaError, MaxGreater, type Modifier, NoStatisticsError, OPTIONAL_COMMENT, type Resultat, SIGN_REGEX, SIGN_REGEX_SPACE, SYMBOL_DICE, type Sign, type Statistic, type StatisticalSchema, type StatisticalTemplate, TooManyDice, TooManyStats, calculator, createCriticalCustom, diceRandomParse, diceTypeRandomParse, escapeRegex, evalCombinaison, evalOneCombinaison, evalStatsDice, generateRandomStat, generateStatsDice, getEngine, getEngineId, isNumber, randomInt, replaceExpByRandom, replaceFormulaInDice, roll, standardizeDice, templateSchema, testDiceRegistered, testStatCombinaison, verifyTemplateValue };
524
+ export { COMMENT_REGEX, type Compare, type ComparedValue, type Critical, type CustomCritical, type CustomCriticalMap, DETECT_CRITICAL, DiceTypeError, EXPLODING_SUCCESS_REGEX, EmptyObjectError, type ExplodingSuccess, FormulaError, MaxGreater, type Modifier, NoStatisticsError, OPTIONAL_COMMENT, type Resultat, SIGN_REGEX, SIGN_REGEX_SPACE, SYMBOL_DICE, type Sign, SortOrder, type Statistic, type StatisticalSchema, type StatisticalTemplate, TooManyDice, TooManyStats, calculator, canComparisonFail, canComparisonSucceed, compareSignFormule, countExplodingSuccesses, createCriticalCustom, diceRandomParse, diceTypeRandomParse, escapeRegex, evalCombinaison, evalOneCombinaison, evalStatsDice, extractValuesFromOutput, fixParenthesis, formatComment, generateRandomStat, generateStatsDice, getCompare, getEngine, getEngineId, getModifier, getRollBounds, inverseSign, isNumber, isTrivialComparison, matchComparison, normalizeExplodingSuccess, randomInt, replaceExpByRandom, replaceFormulaInDice, replaceInFormula, replaceText, replaceUnwantedText, roll, rollCompare, standardizeDice, templateSchema, testDiceRegistered, testStatCombinaison, verifyTemplateValue };