@yipe/dice 0.5.0 → 0.6.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 (57) hide show
  1. package/dist/builder/ac.d.ts +25 -0
  2. package/dist/builder/ac.d.ts.map +1 -0
  3. package/dist/builder/ast.d.ts +9 -0
  4. package/dist/builder/ast.d.ts.map +1 -0
  5. package/dist/builder/attack.d.ts +41 -0
  6. package/dist/builder/attack.d.ts.map +1 -0
  7. package/dist/builder/d20.d.ts +6 -0
  8. package/dist/builder/d20.d.ts.map +1 -0
  9. package/dist/builder/dc.d.ts +26 -0
  10. package/dist/builder/dc.d.ts.map +1 -0
  11. package/dist/builder/example.d.ts +356 -0
  12. package/dist/builder/example.d.ts.map +1 -0
  13. package/dist/builder/factory.d.ts +17 -0
  14. package/dist/builder/factory.d.ts.map +1 -0
  15. package/dist/builder/index.d.ts +8 -429
  16. package/dist/builder/index.d.ts.map +1 -0
  17. package/dist/builder/nodes.d.ts +61 -0
  18. package/dist/builder/nodes.d.ts.map +1 -0
  19. package/dist/builder/prob.d.ts +3 -0
  20. package/dist/builder/prob.d.ts.map +1 -0
  21. package/dist/builder/roll.d.ts +205 -0
  22. package/dist/builder/roll.d.ts.map +1 -0
  23. package/dist/builder/save.d.ts +19 -0
  24. package/dist/builder/save.d.ts.map +1 -0
  25. package/dist/builder/types.d.ts +66 -0
  26. package/dist/builder/types.d.ts.map +1 -0
  27. package/dist/common/bounce.d.ts +32 -0
  28. package/dist/common/bounce.d.ts.map +1 -0
  29. package/dist/common/errors.d.ts +26 -0
  30. package/dist/common/errors.d.ts.map +1 -0
  31. package/dist/common/lru-cache.d.ts +17 -0
  32. package/dist/common/lru-cache.d.ts.map +1 -0
  33. package/dist/common/types.d.ts +65 -0
  34. package/dist/common/types.d.ts.map +1 -0
  35. package/dist/index.d.ts +9 -111
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/parser/dice.d.ts +70 -0
  38. package/dist/parser/dice.d.ts.map +1 -0
  39. package/dist/parser/parser.d.ts +14 -0
  40. package/dist/parser/parser.d.ts.map +1 -0
  41. package/dist/pmf/mixture.d.ts +37 -0
  42. package/dist/pmf/mixture.d.ts.map +1 -0
  43. package/dist/pmf/pmf.d.ts +380 -0
  44. package/dist/pmf/pmf.d.ts.map +1 -0
  45. package/dist/{pmf-D5VRghZI.d.cts → pmf/query.d.ts} +6 -464
  46. package/dist/pmf/query.d.ts.map +1 -0
  47. package/package.json +16 -15
  48. package/.claude/worktrees/amazing-matsumoto-27220c/LICENSE +0 -21
  49. package/.claude/worktrees/amazing-matsumoto-27220c/README.md +0 -518
  50. package/.claude/worktrees/vibrant-lovelace-0cc9e7/LICENSE +0 -21
  51. package/.claude/worktrees/vibrant-lovelace-0cc9e7/README.md +0 -518
  52. package/.claude/worktrees/wizardly-mclean-e375de/LICENSE +0 -21
  53. package/.claude/worktrees/wizardly-mclean-e375de/README.md +0 -518
  54. package/CHANGELOG.md +0 -239
  55. package/dist/builder/index.d.cts +0 -429
  56. package/dist/index.d.cts +0 -111
  57. package/dist/pmf-D5VRghZI.d.ts +0 -1129
package/dist/index.d.cts DELETED
@@ -1,111 +0,0 @@
1
- import { P as PMF } from './pmf-D5VRghZI.cjs';
2
- export { A as ALL_OUTCOME_TYPES, B as Bin, C as CritConfig, D as DamageDistribution, l as DiceQuery, E as EPS, L as LRUCache, M as MISS_NONE_OUTCOME, d as OUTCOME_DISPLAY_ORDER, O as OutcomeLabelMap, m as OutcomeSnapshot, a as OutcomeType, b as RollType, R as Rounding, S as Snapshot, c as critProbability, o as onAnyHit, e as onCritOnly, f as onHitOnly, h as onMissDamageOnly, g as onMissOnly, k as onPotentCantripOnly, j as onSaveFailOnly, i as onSaveHalfOnly, p as pmfCache, s as sortOutcomes } from './pmf-D5VRghZI.cjs';
3
-
4
- /**
5
- * Bounce odds — the "birthday problem" for bouncing damage dice (e.g. Chromatic
6
- * Orb): the probability that at least two of K dice with S faces show the same
7
- * value, which is what lets the spell jump to another target.
8
- *
9
- * Accounts for two modifiers:
10
- * - **Elemental Adept** (`minimumDieRoll >= 2`): rolls below the minimum are
11
- * bumped up to it, collapsing the low faces onto a single heavier value.
12
- * - **Empowered Spell** (`rerollDamageDice > 0`): a number of dice may be
13
- * rerolled once, giving a second chance at a match.
14
- *
15
- * The base and Elemental-Adept cases are computed exactly (see
16
- * {@link pAllDistinct}); the Empowered-Spell reroll is an explicit model layered
17
- * on the exact base match probability.
18
- */
19
- /** Options that modify bounce odds via metamagic / feats. */
20
- interface BounceOddsOptions {
21
- /** Minimum die roll — e.g. 2 for Elemental Adept, 3 for Great Weapon Fighting 2024. */
22
- minimumDieRoll?: number;
23
- /** Number of dice that may be rerolled once — e.g. CHA modifier for Empowered Spell. */
24
- rerollDamageDice?: number;
25
- }
26
- /**
27
- * P(at least two of `diceCount` dice with `dieFaces` faces match), honoring
28
- * Elemental Adept and Empowered Spell. Returns a probability in [0, 1].
29
- *
30
- * @param diceCount Number of dice rolled.
31
- * @param dieFaces Faces per die (e.g. 8 for d8).
32
- * @param options Optional metamagic / feat modifiers.
33
- */
34
- declare function calculateBounceOdds(diceCount: number, dieFaces: number, options?: BounceOddsOptions): number;
35
-
36
- /**
37
- * Error thrown when a dice expression cannot be parsed.
38
- *
39
- * Extends the built-in {@link Error}, so existing `catch (e)` / message checks
40
- * continue to work, while callers can now narrow with `instanceof DiceParseError`.
41
- *
42
- * @example
43
- * try {
44
- * parse("d6@3");
45
- * } catch (e) {
46
- * if (e instanceof DiceParseError) {
47
- * // e.expression === "d6@3"
48
- * }
49
- * }
50
- */
51
- declare class DiceParseError extends Error {
52
- /** The original expression that failed to parse, when available. */
53
- readonly expression?: string;
54
- /** The underlying error that triggered this one, when available. */
55
- readonly cause?: unknown;
56
- constructor(message: string, options?: {
57
- expression?: string;
58
- cause?: unknown;
59
- });
60
- }
61
-
62
- /** Enable or disable the internal parse cache. */
63
- declare function setCachingEnabled(enabled: boolean): void;
64
- /** Returns whether the internal parse cache is currently enabled. */
65
- declare function getCachingEnabled(): boolean;
66
- /** Clears the internal parse cache. */
67
- declare function clearParserCache(): void;
68
- /**
69
- * Parse a dice expression into a PMF.
70
- *
71
- * - Expression is case-insensitive and ignores spaces.
72
- */
73
- declare function parse(expression: string, n?: number): PMF;
74
-
75
- /** A labeled mixture builder that preserves provenance in Bin.count. */
76
- declare class Mixture<L extends string = string> {
77
- private readonly totals;
78
- private readonly labelMass;
79
- private readonly eps;
80
- constructor(eps?: number);
81
- /** Remove all accumulated state. */
82
- clear(): this;
83
- /** Number of distinct outcome values currently accumulated. */
84
- size(): number;
85
- /** Whether a label was ever added. */
86
- hasLabel(label: L): boolean;
87
- /**
88
- * Add a labeled component with a mixture weight.
89
- * Weight can be any positive finite number. Very small contributions are pruned by eps.
90
- */
91
- add(label: L, pmf: PMF, weight?: number): this;
92
- buildPMF(eps?: number): PMF;
93
- /**
94
- * Produce normalized *per-label* PMFs (labels independent).
95
- * These are unlabeled PMFs built from the raw mass of that label alone.
96
- */
97
- byOutcome(): Record<L, PMF>;
98
- /**
99
- * Mixture weights per label, normalized to sum to 1 over labels that appeared.
100
- * Uses raw mass before per-outcome normalization.
101
- */
102
- weights(): Record<L, number>;
103
- toJSON(): {
104
- totals: Array<[number, number]>;
105
- labels: Array<[number, Record<L, number>]>;
106
- eps: number;
107
- };
108
- static mix<L extends string = string>(items: Array<[label: L, pmf: PMF, weight: number]>, eps?: number): PMF;
109
- }
110
-
111
- export { type BounceOddsOptions, DiceParseError, Mixture, PMF, calculateBounceOdds, clearParserCache, getCachingEnabled, parse, setCachingEnabled };