@yipe/dice 0.2.8 → 0.2.10
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/builder/index.cjs
CHANGED
|
@@ -2655,13 +2655,19 @@ var RollBuilder = class _RollBuilder {
|
|
|
2655
2655
|
];
|
|
2656
2656
|
return new this.constructor(configs);
|
|
2657
2657
|
}
|
|
2658
|
-
|
|
2658
|
+
scaleDice(scale) {
|
|
2659
|
+
const scaleInt = Math.floor(scale);
|
|
2660
|
+
if (scaleInt !== scale) throw new Error("Scale must be an integer");
|
|
2661
|
+
if (scaleInt <= 0) throw new Error("Scale must be > 0");
|
|
2659
2662
|
const newConfigs = this.getSubRollConfigs().map((config) => {
|
|
2660
2663
|
if (!config.sides || config.sides <= 0) return config;
|
|
2661
|
-
return { ...config, count: config.count *
|
|
2664
|
+
return { ...config, count: config.count * scaleInt };
|
|
2662
2665
|
});
|
|
2663
2666
|
return new this.constructor(newConfigs);
|
|
2664
2667
|
}
|
|
2668
|
+
doubleDice() {
|
|
2669
|
+
return this.scaleDice(2);
|
|
2670
|
+
}
|
|
2665
2671
|
copy() {
|
|
2666
2672
|
return new this.constructor(this.getSubRollConfigs());
|
|
2667
2673
|
}
|
|
@@ -2692,7 +2698,7 @@ var RollBuilder = class _RollBuilder {
|
|
|
2692
2698
|
let rootD20Group;
|
|
2693
2699
|
if (rootConfig && rootConfig.sides === 20) {
|
|
2694
2700
|
const rootIndex = groupedConfigs.findIndex(
|
|
2695
|
-
({ config }) => config
|
|
2701
|
+
({ config }) => rollConfigsEqual(config, rootConfig) && JSON.stringify(config.keep) === JSON.stringify(rootConfig.keep)
|
|
2696
2702
|
);
|
|
2697
2703
|
if (rootIndex !== -1) {
|
|
2698
2704
|
rootD20Group = groupedConfigs.splice(rootIndex, 1)[0];
|
|
@@ -2731,13 +2737,19 @@ var RollBuilder = class _RollBuilder {
|
|
|
2731
2737
|
const expression = diceExpressions[i];
|
|
2732
2738
|
if (i === 0) {
|
|
2733
2739
|
result = (config.isSubtraction ? "-" : "") + expression;
|
|
2740
|
+
if (config.sides === 20 && totalModifier !== 0) {
|
|
2741
|
+
if (totalModifier > 0) result += ` + ${totalModifier}`;
|
|
2742
|
+
else result += ` - ${Math.abs(totalModifier)}`;
|
|
2743
|
+
}
|
|
2734
2744
|
} else {
|
|
2735
2745
|
const operator = config.isSubtraction ? " - " : " + ";
|
|
2736
2746
|
result += operator + expression;
|
|
2737
2747
|
}
|
|
2738
2748
|
}
|
|
2739
|
-
if (
|
|
2740
|
-
|
|
2749
|
+
if (diceConfigs.length === 0 || diceConfigs[0].sides !== 20) {
|
|
2750
|
+
if (totalModifier > 0) result += ` + ${totalModifier}`;
|
|
2751
|
+
else if (totalModifier < 0) result += ` - ${Math.abs(totalModifier)}`;
|
|
2752
|
+
}
|
|
2741
2753
|
return result.replace(/\+ -/g, "-");
|
|
2742
2754
|
}
|
|
2743
2755
|
toPMF(eps = 0) {
|