@yipe/dice 0.2.16 → 0.2.19
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 +256 -35
- package/dist/builder/index.cjs +947 -12
- package/dist/builder/index.cjs.map +1 -1
- package/dist/builder/index.d.cts +23 -2
- package/dist/builder/index.d.ts +23 -2
- package/dist/builder/index.js +947 -13
- package/dist/builder/index.js.map +1 -1
- package/dist/index.cjs +70 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +70 -2
- package/dist/index.js.map +1 -1
- package/dist/{pmf-CYaEbY7m.d.cts → pmf-BC1poIqF.d.cts} +31 -0
- package/dist/{pmf-CYaEbY7m.d.ts → pmf-BC1poIqF.d.ts} +31 -0
- package/package.json +1 -1
|
@@ -58,8 +58,29 @@ declare const onPotentCantripOnly: OutcomeType[];
|
|
|
58
58
|
declare class DiceQuery {
|
|
59
59
|
readonly singles: PMF[];
|
|
60
60
|
readonly combined: PMF;
|
|
61
|
+
private _combinedWithAttr?;
|
|
61
62
|
constructor(singles: PMF | PMF[], combined?: PMF, eps?: number);
|
|
62
63
|
private static readonly DEFAULT_OUTCOMES;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a new PMF with damage attribution metadata populated.
|
|
66
|
+
*
|
|
67
|
+
* This method computes attribution on-demand for builder-generated PMFs,
|
|
68
|
+
* enabling them to work with damage attribution charts. The `attr` field
|
|
69
|
+
* tracks how much damage each outcome type contributes at each damage value.
|
|
70
|
+
*
|
|
71
|
+
* For each bin at damage D: sum(attr.values()) ≈ D × P(damage = D)
|
|
72
|
+
*
|
|
73
|
+
* Performance: Cached after first call. Adds minimal overhead vs `combined`.
|
|
74
|
+
*
|
|
75
|
+
* @returns PMF with attr field populated for damage attribution charts
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const attack = d20.plus(5).ac(15).onHit(d(2,6).plus(3)).onCrit(d(2,6))
|
|
79
|
+
* const query = attack.toQuery()
|
|
80
|
+
* const pmf = query.combinedWithAttribution()
|
|
81
|
+
* // Now pmf can be used with toDamageAttributionChartSeries()
|
|
82
|
+
*/
|
|
83
|
+
combinedWithAttribution(): PMF;
|
|
63
84
|
/**
|
|
64
85
|
* Returns the expected damage across all possible outcomes.
|
|
65
86
|
*
|
|
@@ -743,6 +764,16 @@ declare class PMF {
|
|
|
743
764
|
pmf: PMF;
|
|
744
765
|
weight: number;
|
|
745
766
|
} | [PMF, number]>, eps?: number): PMF;
|
|
767
|
+
/**
|
|
768
|
+
* Adds damage attribution metadata to this PMF based on existing count metadata.
|
|
769
|
+
* For each bin, sets attr[outcome] = damage × count[outcome].
|
|
770
|
+
*
|
|
771
|
+
* This enables damage attribution charts to work with builder-generated PMFs.
|
|
772
|
+
* The parser generates attr automatically, but builder PMFs only have count.
|
|
773
|
+
*
|
|
774
|
+
* @returns New PMF with attr field populated in each bin
|
|
775
|
+
*/
|
|
776
|
+
withAttribution(): PMF;
|
|
746
777
|
/**
|
|
747
778
|
* General-purpose N-way mixture.
|
|
748
779
|
* weights: Array of [weight, PMF].
|
|
@@ -58,8 +58,29 @@ declare const onPotentCantripOnly: OutcomeType[];
|
|
|
58
58
|
declare class DiceQuery {
|
|
59
59
|
readonly singles: PMF[];
|
|
60
60
|
readonly combined: PMF;
|
|
61
|
+
private _combinedWithAttr?;
|
|
61
62
|
constructor(singles: PMF | PMF[], combined?: PMF, eps?: number);
|
|
62
63
|
private static readonly DEFAULT_OUTCOMES;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a new PMF with damage attribution metadata populated.
|
|
66
|
+
*
|
|
67
|
+
* This method computes attribution on-demand for builder-generated PMFs,
|
|
68
|
+
* enabling them to work with damage attribution charts. The `attr` field
|
|
69
|
+
* tracks how much damage each outcome type contributes at each damage value.
|
|
70
|
+
*
|
|
71
|
+
* For each bin at damage D: sum(attr.values()) ≈ D × P(damage = D)
|
|
72
|
+
*
|
|
73
|
+
* Performance: Cached after first call. Adds minimal overhead vs `combined`.
|
|
74
|
+
*
|
|
75
|
+
* @returns PMF with attr field populated for damage attribution charts
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const attack = d20.plus(5).ac(15).onHit(d(2,6).plus(3)).onCrit(d(2,6))
|
|
79
|
+
* const query = attack.toQuery()
|
|
80
|
+
* const pmf = query.combinedWithAttribution()
|
|
81
|
+
* // Now pmf can be used with toDamageAttributionChartSeries()
|
|
82
|
+
*/
|
|
83
|
+
combinedWithAttribution(): PMF;
|
|
63
84
|
/**
|
|
64
85
|
* Returns the expected damage across all possible outcomes.
|
|
65
86
|
*
|
|
@@ -743,6 +764,16 @@ declare class PMF {
|
|
|
743
764
|
pmf: PMF;
|
|
744
765
|
weight: number;
|
|
745
766
|
} | [PMF, number]>, eps?: number): PMF;
|
|
767
|
+
/**
|
|
768
|
+
* Adds damage attribution metadata to this PMF based on existing count metadata.
|
|
769
|
+
* For each bin, sets attr[outcome] = damage × count[outcome].
|
|
770
|
+
*
|
|
771
|
+
* This enables damage attribution charts to work with builder-generated PMFs.
|
|
772
|
+
* The parser generates attr automatically, but builder PMFs only have count.
|
|
773
|
+
*
|
|
774
|
+
* @returns New PMF with attr field populated in each bin
|
|
775
|
+
*/
|
|
776
|
+
withAttribution(): PMF;
|
|
746
777
|
/**
|
|
747
778
|
* General-purpose N-way mixture.
|
|
748
779
|
* weights: Array of [weight, PMF].
|