@yipe/dice 0.2.8 → 0.2.9

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.
@@ -127,6 +127,7 @@ declare class RollBuilder {
127
127
  add(anotherRoll: RollBuilder | undefined): RollBuilder;
128
128
  withBonus(anotherRoll: RollBuilder): RollBuilder;
129
129
  addRoll(count?: number): RollBuilder;
130
+ scaleDice(scale: number): RollBuilder;
130
131
  doubleDice(): RollBuilder;
131
132
  copy(): RollBuilder;
132
133
  d4: () => RollBuilder;
@@ -127,6 +127,7 @@ declare class RollBuilder {
127
127
  add(anotherRoll: RollBuilder | undefined): RollBuilder;
128
128
  withBonus(anotherRoll: RollBuilder): RollBuilder;
129
129
  addRoll(count?: number): RollBuilder;
130
+ scaleDice(scale: number): RollBuilder;
130
131
  doubleDice(): RollBuilder;
131
132
  copy(): RollBuilder;
132
133
  d4: () => RollBuilder;
@@ -2653,13 +2653,19 @@ var RollBuilder = class _RollBuilder {
2653
2653
  ];
2654
2654
  return new this.constructor(configs);
2655
2655
  }
2656
- doubleDice() {
2656
+ scaleDice(scale) {
2657
+ const scaleInt = Math.floor(scale);
2658
+ if (scaleInt !== scale) throw new Error("Scale must be an integer");
2659
+ if (scaleInt <= 0) throw new Error("Scale must be > 0");
2657
2660
  const newConfigs = this.getSubRollConfigs().map((config) => {
2658
2661
  if (!config.sides || config.sides <= 0) return config;
2659
- return { ...config, count: config.count * 2 };
2662
+ return { ...config, count: config.count * scaleInt };
2660
2663
  });
2661
2664
  return new this.constructor(newConfigs);
2662
2665
  }
2666
+ doubleDice() {
2667
+ return this.scaleDice(2);
2668
+ }
2663
2669
  copy() {
2664
2670
  return new this.constructor(this.getSubRollConfigs());
2665
2671
  }