@yipe/dice 0.8.1 → 0.10.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 +169 -19
- package/dist/builder/ac.d.ts.map +1 -1
- package/dist/builder/ast.d.ts +32 -2
- package/dist/builder/ast.d.ts.map +1 -1
- package/dist/builder/attack.d.ts.map +1 -1
- package/dist/builder/dc.d.ts.map +1 -1
- package/dist/builder/example.d.ts +4 -4
- package/dist/builder/example.d.ts.map +1 -1
- package/dist/builder/index.cjs +889 -90
- package/dist/builder/index.cjs.map +1 -1
- package/dist/builder/index.d.ts +1 -0
- package/dist/builder/index.d.ts.map +1 -1
- package/dist/builder/index.js +886 -91
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/roll.d.ts +5 -1
- package/dist/builder/roll.d.ts.map +1 -1
- package/dist/builder/save.d.ts.map +1 -1
- package/dist/index.cjs +178 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +177 -16
- package/dist/index.js.map +1 -1
- package/dist/parser/dice.d.ts +14 -0
- package/dist/parser/dice.d.ts.map +1 -1
- package/dist/parser/rollType.d.ts +58 -0
- package/dist/parser/rollType.d.ts.map +1 -0
- package/dist/pmf/pmf.d.ts +10 -4
- package/dist/pmf/pmf.d.ts.map +1 -1
- package/dist/pmf/query.d.ts +26 -0
- package/dist/pmf/query.d.ts.map +1 -1
- package/dist/turn/index.d.ts +3 -0
- package/dist/turn/index.d.ts.map +1 -0
- package/dist/turn/plan.d.ts +55 -0
- package/dist/turn/plan.d.ts.map +1 -0
- package/dist/turn/state.d.ts +23 -0
- package/dist/turn/state.d.ts.map +1 -0
- package/dist/turn/turn.d.ts +149 -0
- package/dist/turn/turn.d.ts.map +1 -0
- package/dist/turn/types.d.ts +99 -0
- package/dist/turn/types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/builder/roll.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export declare class RollBuilder {
|
|
|
37
37
|
reroll(value: number): RollBuilder;
|
|
38
38
|
/** Set finite explode count for max-face explosions (Infinity allowed). */
|
|
39
39
|
explode(count?: number | undefined): RollBuilder;
|
|
40
|
-
/** Apply per-die minimum value (
|
|
40
|
+
/** Apply per-die minimum value (floors each die roll at `val`, e.g. `minimum(3)` treats a 1 or
|
|
41
|
+
* 2 as a 3 -- the 2024 Great Weapon Fighting style). */
|
|
41
42
|
minimum(val: number | undefined): RollBuilder;
|
|
42
43
|
bestOf(count: number | undefined): RollBuilder;
|
|
43
44
|
keepHighest(total: number, count: number): RollBuilder;
|
|
@@ -97,6 +98,7 @@ export declare class HalfRollBuilder extends RollBuilder {
|
|
|
97
98
|
toExpression(): string;
|
|
98
99
|
toAST(): ExpressionNode;
|
|
99
100
|
toPMF(eps?: number): PMF;
|
|
101
|
+
scaleDice(scale: number): RollBuilder;
|
|
100
102
|
copy(): HalfRollBuilder;
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
@@ -117,6 +119,7 @@ export declare class ScaleRollBuilder extends RollBuilder {
|
|
|
117
119
|
toExpression(): string;
|
|
118
120
|
toAST(): ExpressionNode;
|
|
119
121
|
toPMF(eps?: number): PMF;
|
|
122
|
+
scaleDice(scale: number): RollBuilder;
|
|
120
123
|
copy(): ScaleRollBuilder;
|
|
121
124
|
}
|
|
122
125
|
export declare class MaxOfRollBuilder extends RollBuilder {
|
|
@@ -132,6 +135,7 @@ export declare class MaxOfRollBuilder extends RollBuilder {
|
|
|
132
135
|
toExpression(): string;
|
|
133
136
|
toAST(): ExpressionNode;
|
|
134
137
|
toPMF(eps?: number): PMF;
|
|
138
|
+
scaleDice(scale: number): RollBuilder;
|
|
135
139
|
copy(): MaxOfRollBuilder;
|
|
136
140
|
}
|
|
137
141
|
export declare class AlwaysHitBuilder extends RollBuilder {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roll.d.ts","sourceRoot":"","sources":["../../src/builder/roll.ts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AgB,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,CAKnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../src/builder/save.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../src/builder/save.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAU5C,8FAA8F;AAC9F,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,qBAAa,WAAY,YAAW,YAAY;IAE5C,QAAQ,CAAC,KAAK,EAAE,SAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAH9B,YACW,KAAK,EAAE,SAAS,EACR,aAAa,CAAC,EAAE,WAAW,YAAA,EAC3B,WAAW,GAAE,WAAsB,EAClD;IAEJ,QAAQ,IAAI,WAAW,CAEtB;IAED,YAAY,IAAI,MAAM,CAOrB;IAED,OAAO,CAAC,GAAG,GAAE,MAAY,GAAG,cAAc,CA8BzC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAehB,KAAK,CAAC,GAAG,GAAE,MAAU,GAAG,GAAG,CAQ1B;IAED,IAAI,GAAG,QAEN;IAGD,OAAO,CAAC,GAAG,GAAE,MAAU,GAAG,SAAS,CAElC;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -209,6 +209,10 @@ var _DiceQuery = class _DiceQuery {
|
|
|
209
209
|
if (this._combinedWithAttr) {
|
|
210
210
|
return this._combinedWithAttr;
|
|
211
211
|
}
|
|
212
|
+
if (this._combinedProvided) {
|
|
213
|
+
this._combinedWithAttr = this.combined.withAttribution();
|
|
214
|
+
return this._combinedWithAttr;
|
|
215
|
+
}
|
|
212
216
|
if (this.singles.every((pmf) => pmf.hasAttribution())) {
|
|
213
217
|
this._combinedWithAttr = this.combined;
|
|
214
218
|
return this._combinedWithAttr;
|
|
@@ -979,6 +983,55 @@ var _DiceQuery = class _DiceQuery {
|
|
|
979
983
|
}
|
|
980
984
|
return out;
|
|
981
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Per-outcome probabilities and damage ranges, aggregated over the individual
|
|
988
|
+
* singles rather than read off the combined distribution.
|
|
989
|
+
*
|
|
990
|
+
* `damageRange` is the sum, over every single that can produce the outcome, of
|
|
991
|
+
* that single's own conditional damage range: "what this outcome contributes
|
|
992
|
+
* across the whole turn when every attack that can produce it does". Linear in
|
|
993
|
+
* the number of attacks by construction.
|
|
994
|
+
*
|
|
995
|
+
* Prefer this over {@link DiceQuery.snapshot} for a multi-attack query.
|
|
996
|
+
* `snapshot` reads `damageRange` off the combined PMF's `count`, which the
|
|
997
|
+
* convolution accumulates as an expected count, so its `avg` is size-biased
|
|
998
|
+
* for N≥2 (its own doc comment says so). The two agree for a single attack.
|
|
999
|
+
*
|
|
1000
|
+
* Only outcomes that actually occur appear in the result.
|
|
1001
|
+
*
|
|
1002
|
+
* Like every `singles`-based helper on this class, it describes the singles
|
|
1003
|
+
* and not an explicitly provided `combined`. `Turn.toQuery()` supplies one whose
|
|
1004
|
+
* distribution also contains rider attacks that are absent from `singles`
|
|
1005
|
+
* (an `otherwise([unarmed, unarmed])` flurry, say), so those attacks do not
|
|
1006
|
+
* appear here. For rider-inclusive figures read the combined distribution
|
|
1007
|
+
* directly: {@link DiceQuery.outcomeTotals}, {@link DiceQuery.outcomeDamageRanges}.
|
|
1008
|
+
*
|
|
1009
|
+
* @param outcomes Which outcomes to consider; defaults to every canonical one.
|
|
1010
|
+
*/
|
|
1011
|
+
outcomeStats(outcomes = ALL_OUTCOME_TYPES) {
|
|
1012
|
+
const stats = /* @__PURE__ */ new Map();
|
|
1013
|
+
const perSingle = this.singles.map((pmf) => new _DiceQuery([pmf], void 0, this._eps));
|
|
1014
|
+
for (const outcome of outcomes) {
|
|
1015
|
+
const atLeastOneProbability = this.probAtLeastOne(outcome);
|
|
1016
|
+
if (atLeastOneProbability <= 0) continue;
|
|
1017
|
+
const damageRange = { min: 0, avg: 0, max: 0 };
|
|
1018
|
+
let contributors = 0;
|
|
1019
|
+
for (const single of perSingle) {
|
|
1020
|
+
if (single.probAtLeastOne(outcome) <= 0) continue;
|
|
1021
|
+
contributors++;
|
|
1022
|
+
const stat = single.damageStatsFrom(outcome);
|
|
1023
|
+
damageRange.min += stat.min;
|
|
1024
|
+
damageRange.avg += stat.avg;
|
|
1025
|
+
damageRange.max += stat.max;
|
|
1026
|
+
}
|
|
1027
|
+
stats.set(outcome, {
|
|
1028
|
+
atLeastOneProbability,
|
|
1029
|
+
allProbability: contributors > 0 ? this.probExactlyK(outcome, contributors) : 0,
|
|
1030
|
+
damageRange
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
return stats;
|
|
1034
|
+
}
|
|
982
1035
|
/**
|
|
983
1036
|
* Snapshot of the distribution in the exact shape the UI consumes.
|
|
984
1037
|
* - outcome probabilities are "at least one" (and equal to "all" for a single PMF)
|
|
@@ -1515,7 +1568,7 @@ var _PMF = class _PMF {
|
|
|
1515
1568
|
const id = this.identifier;
|
|
1516
1569
|
let key = `${id}`;
|
|
1517
1570
|
for (let i = 1; i < n; i++) key += `+${id}`;
|
|
1518
|
-
return `${key}@${eps}`;
|
|
1571
|
+
return `${key}@${eps}|${this.fingerprint()}`;
|
|
1519
1572
|
}
|
|
1520
1573
|
/**
|
|
1521
1574
|
* Efficiently computes this PMF convolved with itself `n` times.
|
|
@@ -1866,16 +1919,27 @@ var _PMF = class _PMF {
|
|
|
1866
1919
|
return `v4:${raw ? "RAW" : "N"}:${id1}+${id2}@${eps}|${p1.fingerprint()}|${p2.fingerprint()}`;
|
|
1867
1920
|
}
|
|
1868
1921
|
/**
|
|
1869
|
-
* A
|
|
1870
|
-
* cache keys change
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1922
|
+
* A content fingerprint of every bin (probability, per-label `count`, per-label `attr`) plus
|
|
1923
|
+
* the `normalized` flag, so convolution/power cache keys change whenever the underlying
|
|
1924
|
+
* numbers do. Mass/bin-count/face-sum alone are not content-unique: `mapDamage` variants can
|
|
1925
|
+
* keep the same identifier, support, mass, and face sum while differing in per-bin
|
|
1926
|
+
* probabilities or in the `count`/`attr` channels `convolve()`/`power()` actually propagate --
|
|
1927
|
+
* that previously let `power()` return one PMF's cached result for a different PMF. Memoized
|
|
1928
|
+
* because a PMF is immutable once constructed -- this avoids re-deriving the key on every
|
|
1929
|
+
* convolve()/power() call (including cache hits). Bin order is sorted by damage value (and
|
|
1930
|
+
* label keys sorted within each bin) so two equal-content PMFs built via different code paths
|
|
1931
|
+
* fingerprint identically regardless of Map insertion order.
|
|
1873
1932
|
*/
|
|
1874
1933
|
fingerprint() {
|
|
1875
1934
|
if (this._fingerprint === void 0) {
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1935
|
+
const bins = [...this.map.entries()].sort((a, b) => a[0] - b[0]);
|
|
1936
|
+
const parts = [];
|
|
1937
|
+
for (const [damageValue, bin] of bins) {
|
|
1938
|
+
const countStr = Object.keys(bin.count).sort().map((k) => `${k}:${bin.count[k]}`).join(",");
|
|
1939
|
+
const attrStr = bin.attr ? Object.keys(bin.attr).sort().map((k) => `${k}:${bin.attr[k]}`).join(",") : "";
|
|
1940
|
+
parts.push(`${damageValue}:${bin.p}[${countStr}]{${attrStr}}`);
|
|
1941
|
+
}
|
|
1942
|
+
this._fingerprint = `${this.normalized ? 1 : 0}|${parts.join(";")}`;
|
|
1879
1943
|
}
|
|
1880
1944
|
return this._fingerprint;
|
|
1881
1945
|
}
|
|
@@ -2107,11 +2171,13 @@ var _PMF = class _PMF {
|
|
|
2107
2171
|
/** Quantile / inverse CDF for p in [0,1]. Returns smallest x with CDF ≥ p. */
|
|
2108
2172
|
quantile(p) {
|
|
2109
2173
|
if (this.map.size === 0) return 0;
|
|
2174
|
+
const totalMass = this.mass();
|
|
2175
|
+
if (totalMass <= 0) return 0;
|
|
2110
2176
|
const s = this.support().sort((a, b) => a - b);
|
|
2111
2177
|
let acc = 0;
|
|
2112
2178
|
for (const x of s) {
|
|
2113
2179
|
acc += this.pAt(x);
|
|
2114
|
-
if (acc >= p) return x;
|
|
2180
|
+
if (acc / totalMass >= p) return x;
|
|
2115
2181
|
}
|
|
2116
2182
|
return s[s.length - 1];
|
|
2117
2183
|
}
|
|
@@ -2972,6 +3038,12 @@ function combineDiceWithNormalization(dice, normValue, outcomeType, currentNorm,
|
|
|
2972
3038
|
finalResult = finalResult.combine(dice);
|
|
2973
3039
|
return { newNorm: currentNorm * normValue, updatedResult: finalResult };
|
|
2974
3040
|
}
|
|
3041
|
+
function subtractCounts(a, b) {
|
|
3042
|
+
const result = new Dice();
|
|
3043
|
+
for (const [key, value] of a.getFaceEntries()) result.increment(key, value);
|
|
3044
|
+
for (const [key, value] of b.getFaceEntries()) result.increment(key, -value);
|
|
3045
|
+
return result;
|
|
3046
|
+
}
|
|
2975
3047
|
function parseExpression(arr, n) {
|
|
2976
3048
|
const result = (() => {
|
|
2977
3049
|
const res = parseArgument(arr, n);
|
|
@@ -2979,8 +3051,29 @@ function parseExpression(arr, n) {
|
|
|
2979
3051
|
})();
|
|
2980
3052
|
let op = parseOperation(arr);
|
|
2981
3053
|
let finalResult = result;
|
|
3054
|
+
let baseDieMeta = result.privateData?.checkDie && !result.privateData.checkDie.rerollOne ? result.privateData.checkDie : void 0;
|
|
3055
|
+
let bonusOnly = Dice.scalar(0);
|
|
2982
3056
|
while (op != null) {
|
|
2983
3057
|
const arg = !op.unary ? parseArgument(arr, n) : finalResult;
|
|
3058
|
+
let acAlreadyApplied = false;
|
|
3059
|
+
if (baseDieMeta) {
|
|
3060
|
+
if (op === Dice.prototype.addNonZero) {
|
|
3061
|
+
bonusOnly = bonusOnly.add(arg);
|
|
3062
|
+
} else if (op === Dice.prototype.subtract) {
|
|
3063
|
+
bonusOnly = bonusOnly.subtract(arg);
|
|
3064
|
+
} else if (op === Dice.prototype.ac && typeof arg === "number") {
|
|
3065
|
+
const natMaxSlice = bonusOnly.add(baseDieMeta.sides);
|
|
3066
|
+
const restSlice = subtractCounts(finalResult, natMaxSlice);
|
|
3067
|
+
const gatedNatMaxSlice = natMaxSlice.ac(arg);
|
|
3068
|
+
finalResult = restSlice.ac(arg).combine(gatedNatMaxSlice);
|
|
3069
|
+
finalResult.privateData.checkDie = baseDieMeta;
|
|
3070
|
+
finalResult.privateData.natMaxCritSlice = gatedNatMaxSlice;
|
|
3071
|
+
acAlreadyApplied = true;
|
|
3072
|
+
baseDieMeta = void 0;
|
|
3073
|
+
} else {
|
|
3074
|
+
baseDieMeta = void 0;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
2984
3077
|
let crit;
|
|
2985
3078
|
let critNorm = 1;
|
|
2986
3079
|
if (arr[0] === "x" || arr[0] === "c") {
|
|
@@ -2991,11 +3084,17 @@ function parseExpression(arr, n) {
|
|
|
2991
3084
|
assertToken(arr, "i");
|
|
2992
3085
|
assertToken(arr, "t");
|
|
2993
3086
|
const count = isXcrit ? parseNumber(arr, n) : 1;
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3087
|
+
const trackedCritSlice = finalResult.privateData?.natMaxCritSlice;
|
|
3088
|
+
if (count === 1 && trackedCritSlice) {
|
|
3089
|
+
crit = trackedCritSlice;
|
|
3090
|
+
finalResult = subtractCounts(finalResult, trackedCritSlice);
|
|
3091
|
+
} else {
|
|
3092
|
+
crit = new Dice();
|
|
3093
|
+
for (let i = 0; i < count; i++) {
|
|
3094
|
+
const max = finalResult.maxFace();
|
|
3095
|
+
crit.setFace(max, finalResult.get(max));
|
|
3096
|
+
finalResult = finalResult.deleteFace(max);
|
|
3097
|
+
}
|
|
2999
3098
|
}
|
|
3000
3099
|
critNorm = crit.total();
|
|
3001
3100
|
crit = op.call(crit, parseBinaryArgument(arg, arr, n));
|
|
@@ -3046,7 +3145,9 @@ function parseExpression(arr, n) {
|
|
|
3046
3145
|
missNorm = miss && missNorm ? miss.total() / missNorm : 1;
|
|
3047
3146
|
}
|
|
3048
3147
|
let norm = finalResult.total();
|
|
3049
|
-
|
|
3148
|
+
if (!acAlreadyApplied) {
|
|
3149
|
+
finalResult = op.call(finalResult, arg);
|
|
3150
|
+
}
|
|
3050
3151
|
norm = norm ? finalResult.total() / norm : 1;
|
|
3051
3152
|
if (crit) {
|
|
3052
3153
|
const result2 = combineDiceWithNormalization(
|
|
@@ -3237,6 +3338,7 @@ function parseDice(s, n) {
|
|
|
3237
3338
|
if (rerollOne) {
|
|
3238
3339
|
result = result.reroll(1);
|
|
3239
3340
|
}
|
|
3341
|
+
result.privateData.checkDie = { sides, rerollOne };
|
|
3240
3342
|
return result;
|
|
3241
3343
|
}
|
|
3242
3344
|
function peek(arr, expected) {
|
|
@@ -3347,6 +3449,65 @@ function parseOperation(s) {
|
|
|
3347
3449
|
return;
|
|
3348
3450
|
}
|
|
3349
3451
|
|
|
3452
|
+
// src/parser/rollType.ts
|
|
3453
|
+
var DECIMAL_INTEGER = /^\s*[+-]?\d+\s*$/;
|
|
3454
|
+
function tryParse(expression) {
|
|
3455
|
+
if (DECIMAL_INTEGER.test(expression)) {
|
|
3456
|
+
const value = Number(expression);
|
|
3457
|
+
return Number.isSafeInteger(value) ? PMF.delta(value) : PMF.empty();
|
|
3458
|
+
}
|
|
3459
|
+
try {
|
|
3460
|
+
return parse(expression);
|
|
3461
|
+
} catch {
|
|
3462
|
+
return PMF.empty();
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
var CHECK_TOKEN = /\b(AC|DC)\b/i;
|
|
3466
|
+
var D20_RUN = /\bh?d20(?:\s*[><]\s*h?d20)*/i;
|
|
3467
|
+
var RUN_FOR_ROLL_TYPE = {
|
|
3468
|
+
flat: "d20",
|
|
3469
|
+
advantage: "d20 > d20",
|
|
3470
|
+
disadvantage: "d20 < d20",
|
|
3471
|
+
"elven accuracy": "d20 > d20 > d20"
|
|
3472
|
+
};
|
|
3473
|
+
function withRollType(expression, rollType) {
|
|
3474
|
+
const scopes = enclosingScopes(expression);
|
|
3475
|
+
let rewritten = "";
|
|
3476
|
+
let copiedUpTo = 0;
|
|
3477
|
+
for (const run of expression.matchAll(new RegExp(D20_RUN, "gi"))) {
|
|
3478
|
+
const at = run.index;
|
|
3479
|
+
if (!isAttackRoll(expression, scopes, at)) continue;
|
|
3480
|
+
const replacement = run[0].toLowerCase().startsWith("h") ? `h${RUN_FOR_ROLL_TYPE[rollType]}` : RUN_FOR_ROLL_TYPE[rollType];
|
|
3481
|
+
rewritten += expression.slice(copiedUpTo, at) + replacement;
|
|
3482
|
+
copiedUpTo = at + run[0].length;
|
|
3483
|
+
}
|
|
3484
|
+
return rewritten + expression.slice(copiedUpTo);
|
|
3485
|
+
}
|
|
3486
|
+
function enclosingScopes(expression) {
|
|
3487
|
+
const open = [];
|
|
3488
|
+
const scopes = [];
|
|
3489
|
+
for (let i = 0; i < expression.length; i++) {
|
|
3490
|
+
if (expression[i] === "(") open.push(i);
|
|
3491
|
+
else if (expression[i] === ")") {
|
|
3492
|
+
const start = open.pop();
|
|
3493
|
+
if (start !== void 0) scopes.push({ start, end: i + 1 });
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
return scopes.sort((a, b) => a.end - a.start - (b.end - b.start));
|
|
3497
|
+
}
|
|
3498
|
+
function isAttackRoll(expression, scopes, at) {
|
|
3499
|
+
let scoped = false;
|
|
3500
|
+
for (const scope of scopes) {
|
|
3501
|
+
if (at < scope.start || at >= scope.end) continue;
|
|
3502
|
+
scoped = true;
|
|
3503
|
+
const check2 = CHECK_TOKEN.exec(expression.slice(scope.start, scope.end));
|
|
3504
|
+
if (check2) return check2[1].toUpperCase() === "AC";
|
|
3505
|
+
}
|
|
3506
|
+
if (scoped) return false;
|
|
3507
|
+
const check = CHECK_TOKEN.exec(expression);
|
|
3508
|
+
return check !== null && check[1].toUpperCase() === "AC";
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3350
3511
|
// src/pmf/mixture.ts
|
|
3351
3512
|
var Mixture = class _Mixture {
|
|
3352
3513
|
constructor(eps = EPS) {
|
|
@@ -3490,5 +3651,7 @@ exports.parse = parse;
|
|
|
3490
3651
|
exports.pmfCache = pmfCache;
|
|
3491
3652
|
exports.setCachingEnabled = setCachingEnabled;
|
|
3492
3653
|
exports.sortOutcomes = sortOutcomes;
|
|
3654
|
+
exports.tryParse = tryParse;
|
|
3655
|
+
exports.withRollType = withRollType;
|
|
3493
3656
|
//# sourceMappingURL=index.cjs.map
|
|
3494
3657
|
//# sourceMappingURL=index.cjs.map
|