KeepModifier
KeepModifier ⇐ Modifier
A KeepModifier will "keep" dice from a roll, dropping (Remove from total calculations) all others.
Kind: global class
Extends: Modifier
See: DropModifier for the opposite of this modifier
- KeepModifier ⇐
Modifier- new KeepModifier([end], [qty])
- .order :
number - .end ⇒
string - .end
- .name ⇒
string - .notation ⇒
string - .qty ⇒
number - .qty
- .rangeToDrop(_results) ⇒
Array.<number> - .run(results, _context) ⇒
ResultGroup|RollResults - .toJSON() ⇒
Object
new KeepModifier([end], [qty])
Create a KeepModifier instance
Throws:
RangeErrorEnd must be one of 'h' or 'l'TypeErrorqty must be a positive integer
| Param | Type | Default | Description |
|---|---|---|---|
| [end] | string | "h" | Either `h |
| [qty] | number | 1 | The amount dice to keep |
keepModifier.order : number
The default modifier execution order.
Kind: instance property of KeepModifier
keepModifier.end ⇒ string
Which end the rolls should be kept ("h" = High, "l" = Low).
Kind: instance property of KeepModifier
Returns: string - 'h' or 'l'
keepModifier.end
Set which end the rolls should be kept ("h" = High, "l" = Low).
Kind: instance property of KeepModifier
Throws:
RangeErrorEnd must be one of 'h' or 'l'
| Param | Type | Description |
|---|---|---|
| value | string | Either 'h' or 'l' |
keepModifier.name ⇒ string
The name of the modifier.
Kind: instance property of KeepModifier
Returns: string - 'keep-l' or 'keep-h'
keepModifier.notation ⇒ string
The modifier's notation.
Kind: instance property of KeepModifier
keepModifier.qty ⇒ number
The quantity of dice that should be kept.
Kind: instance property of KeepModifier
keepModifier.qty
Set the quantity of dice that should be kept.
Kind: instance property of KeepModifier
Throws:
TypeErrorqty must be a positive finite integer
| Param | Type |
|---|---|
| value | number |
keepModifier.rangeToDrop(_results) ⇒ Array.<number>
Determine the start and end (end exclusive) range of rolls to drop.
Kind: instance method of KeepModifier
Returns: Array.<number> - The min / max range to drop
| Param | Type | Description |
|---|---|---|
| _results | RollResults | The results to drop from |
keepModifier.run(results, _context) ⇒ ResultGroup | RollResults
Run the modifier on the results.
Kind: instance method of KeepModifier
Returns: ResultGroup | RollResults - The modified results
| Param | Type | Description |
|---|---|---|
| results | ResultGroup | RollResults | The results to run the modifier against |
| _context | StandardDice | RollGroup | The object that the modifier is attached to |
keepModifier.toJSON() ⇒ Object
Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of KeepModifier