@platonic-dice/core 2.1.2 → 3.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.
Files changed (66) hide show
  1. package/README.md +11 -2
  2. package/dist/analyseModTest.js +12 -10
  3. package/dist/analyseTest.js +43 -11
  4. package/dist/entities/DiceTestConditions.js +174 -0
  5. package/dist/entities/ModifiedTestConditions.js +30 -41
  6. package/dist/entities/RollModifier.js +15 -1
  7. package/dist/entities/TestConditions.js +26 -182
  8. package/dist/entities/TestConditionsArray.js +87 -0
  9. package/dist/entities/index.js +250 -39
  10. package/dist/index.js +42 -25
  11. package/dist/rollDiceMod.js +30 -17
  12. package/dist/rollDiceTest.js +68 -0
  13. package/dist/rollMod.js +3 -4
  14. package/dist/rollModTest.js +40 -13
  15. package/dist/rollTest.js +50 -15
  16. package/dist/utils/determineOutcome.js +35 -7
  17. package/dist/utils/getArrayEvaluator.js +48 -0
  18. package/dist/utils/getEvaluator.js +84 -0
  19. package/dist/utils/index.js +244 -16
  20. package/dist/utils/outcomeMapper.js +62 -15
  21. package/dist/utils/testRegistry.js +91 -0
  22. package/dist/utils/testValidators.js +190 -0
  23. package/package.json +15 -17
  24. package/dist/analyseModTest.d.ts +0 -126
  25. package/dist/analyseModTest.d.ts.map +0 -1
  26. package/dist/analyseTest.d.ts +0 -101
  27. package/dist/analyseTest.d.ts.map +0 -1
  28. package/dist/entities/DieType.d.ts +0 -35
  29. package/dist/entities/DieType.d.ts.map +0 -1
  30. package/dist/entities/ModifiedTestConditions.d.ts +0 -89
  31. package/dist/entities/ModifiedTestConditions.d.ts.map +0 -1
  32. package/dist/entities/Outcome.d.ts +0 -26
  33. package/dist/entities/Outcome.d.ts.map +0 -1
  34. package/dist/entities/RollModifier.d.ts +0 -115
  35. package/dist/entities/RollModifier.d.ts.map +0 -1
  36. package/dist/entities/RollType.d.ts +0 -24
  37. package/dist/entities/RollType.d.ts.map +0 -1
  38. package/dist/entities/TestConditions.d.ts +0 -97
  39. package/dist/entities/TestConditions.d.ts.map +0 -1
  40. package/dist/entities/TestType.d.ts +0 -28
  41. package/dist/entities/TestType.d.ts.map +0 -1
  42. package/dist/entities/index.d.ts +0 -19
  43. package/dist/entities/index.d.ts.map +0 -1
  44. package/dist/index.d.ts +0 -5
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/roll.d.ts +0 -66
  47. package/dist/roll.d.ts.map +0 -1
  48. package/dist/rollDice.d.ts +0 -48
  49. package/dist/rollDice.d.ts.map +0 -1
  50. package/dist/rollDiceMod.d.ts +0 -54
  51. package/dist/rollDiceMod.d.ts.map +0 -1
  52. package/dist/rollMod.d.ts +0 -52
  53. package/dist/rollMod.d.ts.map +0 -1
  54. package/dist/rollModTest.d.ts +0 -72
  55. package/dist/rollModTest.d.ts.map +0 -1
  56. package/dist/rollTest.d.ts +0 -59
  57. package/dist/rollTest.d.ts.map +0 -1
  58. package/dist/utils/determineOutcome.d.ts +0 -45
  59. package/dist/utils/determineOutcome.d.ts.map +0 -1
  60. package/dist/utils/generateResult.d.ts +0 -30
  61. package/dist/utils/generateResult.d.ts.map +0 -1
  62. package/dist/utils/index.d.ts +0 -8
  63. package/dist/utils/index.d.ts.map +0 -1
  64. package/dist/utils/outcomeMapper.d.ts +0 -29
  65. package/dist/utils/outcomeMapper.d.ts.map +0 -1
  66. package/dist-types.d.ts +0 -70
@@ -1,29 +0,0 @@
1
- /**
2
- * Creates an outcome map for all possible base rolls given the configuration.
3
- * Uses memoization cache for performance.
4
- *
5
- * @param {import("../entities/DieType").DieTypeValue} dieType - The type of die
6
- * @param {import("../entities/TestType").TestTypeValue} testType - The type of test being performed
7
- * @param {import("../entities/TestConditions").TestConditionsInstance} testConditions - The test conditions
8
- * @param {import("../entities/RollModifier").RollModifierInstance|null} modifier - Optional modifier to apply
9
- * @param {boolean|null} useNaturalCrits - Whether to use natural crits (null = auto-determine)
10
- * @returns {Object.<number, import("../entities/Outcome").OutcomeValue>} Map of baseRoll -> outcome
11
- */
12
- export function createOutcomeMap(dieType: import("../entities/DieType").DieTypeValue, testType: import("../entities/TestType").TestTypeValue, testConditions: import("../entities/TestConditions").TestConditionsInstance, modifier?: import("../entities/RollModifier").RollModifierInstance | null, useNaturalCrits?: boolean | null): {
13
- [x: number]: import("../entities").OutcomeValue;
14
- };
15
- /**
16
- * Clears the outcome map cache.
17
- * Useful for testing or memory management.
18
- *
19
- * @function clearOutcomeMapCache
20
- */
21
- export function clearOutcomeMapCache(): void;
22
- /**
23
- * Gets the current size of the outcome map cache.
24
- *
25
- * @function getOutcomeMapCacheSize
26
- * @returns {number}
27
- */
28
- export function getOutcomeMapCacheSize(): number;
29
- //# sourceMappingURL=outcomeMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outcomeMapper.d.ts","sourceRoot":"","sources":["../../src/utils/outcomeMapper.js"],"names":[],"mappings":"AAsGA;;;;;;;;;;GAUG;AACH,0CAPW,OAAO,qBAAqB,EAAE,YAAY,YAC1C,OAAO,sBAAsB,EAAE,aAAa,kBAC5C,OAAO,4BAA4B,EAAE,sBAAsB,aAC3D,OAAO,0BAA0B,EAAE,oBAAoB,GAAC,IAAI,oBAC5D,OAAO,GAAC,IAAI;;EA4DtB;AAED;;;;;GAKG;AACH,6CAEC;AAED;;;;;GAKG;AACH,0CAFa,MAAM,CAIlB"}
package/dist-types.d.ts DELETED
@@ -1,70 +0,0 @@
1
- // Convenience type re-exports for consumers. This file points at the generated
2
- // declaration files in `dist/entities` so TypeScript users can import type
3
- // aliases directly from the package root via the `types` field.
4
-
5
- export type {
6
- RollModifierFunction,
7
- RollModifierInstance,
8
- } from "./dist/entities/RollModifier";
9
- export type { OutcomeValue } from "./dist/entities/Outcome";
10
- export type { TestConditionsInstance } from "./dist/entities/TestConditions";
11
- export type { RollTypeValue } from "./dist/entities/RollType";
12
- export type { TestTypeValue } from "./dist/entities/TestType";
13
- export type { DieTypeValue } from "./dist/entities/DieType";
14
-
15
- // Re-export other commonly used entity types
16
- export * from "./dist/entities/index";
17
-
18
- // Re-export top-level runtime APIs (roll helpers) so consumers can import
19
- // functions like `roll`, `rollMod`, and `rollTest` from the package root.
20
- export * from "./dist/roll";
21
- export * from "./dist/rollMod";
22
- export * from "./dist/rollDice";
23
- export * from "./dist/rollDiceMod";
24
- export * from "./dist/rollTest";
25
- export * from "./dist/rollModTest";
26
- export * from "./dist/analyseTest";
27
- export * from "./dist/analyseModTest";
28
-
29
- // The `rollMod`/`rollTest`/`rollModTest` d.ts files are emitted using a CommonJS `export =`
30
- // shape which doesn't always expose named exports for consumers under some
31
- // moduleResolution strategies. Provide explicit ESM-style type declarations
32
- // here so TypeScript imports like `import { rollMod } from '@platonic-dice/core'`
33
- // resolve correctly.
34
- export function rollMod(
35
- dieType: import("./dist/entities/DieType").DieTypeValue,
36
- modifier:
37
- | import("./dist/entities/RollModifier").RollModifierFunction
38
- | import("./dist/entities/RollModifier").RollModifierInstance,
39
- rollType?: import("./dist/entities/RollType").RollTypeValue
40
- ): { base: number; modified: number };
41
-
42
- export function rollTest(
43
- dieType: import("./dist/entities/DieType").DieTypeValue,
44
- testConditions:
45
- | import("./dist/entities/TestConditions").TestConditionsInstance
46
- | {
47
- testType: import("./dist/entities/TestType").TestTypeValue;
48
- [k: string]: any;
49
- },
50
- rollType?: import("./dist/entities/RollType").RollTypeValue
51
- ): { base: number; outcome: import("./dist/entities/Outcome").OutcomeValue };
52
-
53
- export function rollModTest(
54
- dieType: import("./dist/entities/DieType").DieTypeValue,
55
- modifier:
56
- | import("./dist/entities/RollModifier").RollModifierFunction
57
- | import("./dist/entities/RollModifier").RollModifierInstance,
58
- testConditions:
59
- | import("./dist/entities/TestConditions").TestConditionsInstance
60
- | {
61
- testType: import("./dist/entities/TestType").TestTypeValue;
62
- [k: string]: any;
63
- },
64
- rollType?: import("./dist/entities/RollType").RollTypeValue,
65
- options?: { useNaturalCrits?: boolean }
66
- ): {
67
- base: number;
68
- modified: number;
69
- outcome: import("./dist/entities/Outcome").OutcomeValue;
70
- };