@idlework/dice
v1.0.0
Published
A simple dice system in which you indicate the number of dice and how many sides the dice has. After rolling the dice the total is available but also the individual dice from the tray.
Downloads
1
Maintainers
Readme
Dice
Installation
$ npm i @idlework/dice --save
Usage
import Dice from 'dice'
export default class Map extends Dice {
constructor (dice, faces) {
super(dice, faces)
}
}
or
import Dice from 'dice'
const dice = new Dice(2, 6)
or
const Dice = require('dice')
const dice = new Dice(2, 6)
API
constructor
Intitialize Dice class.
Parameters
dice
Number Number corresponding with the amount of dice.faces
Number Number corresponding with the amount of faces on the dice.
roll
Roll the dice.
Returns Number Returns the total of all dice.
clearTray
Clears the tray from dice. Result and tray will be cleared.
dice
Return the amount of dice.
Returns Number Return the amount of dice.
faces
Returns the amount of faces on a the dice.
Returns Number Returns the amount of faces on a the dice.
result
Returns the total of all the dice.
Returns Number Returns the total of all the dice.
tray
Returns the tray(array) with all the dice.
Returns Array Return an array with all the dice.
Contributing
Issues are welcome. The best way to report a problem is to reproduce it with a code example.
Pull requests are welcome. If you want to change the API, it's better to discuss it using an issue ticket.
License
Dice is MIT licensed.