npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dnd-dice-complete-set

v1.0.5

Published

Dungeons & Dragons RPG dice set functions to be used in any project.

Downloads

26

Readme

dnd-dice-complete-set

A Library with many different dice rolling functions, first used for personal projects, but now available for anyone who wants to use it.

Installing

npm install dnd-dice-complete-set

Importing

import {rollD20} from 'dnd-dice-complete-set'

Content:

Platonic Solids (Basic RPG Dice Set)

Calling any of the functions below, returns dice result for respesctive dice.

rollD4()  // returns random number from 1 to 4  
rollD6()  // returns random number from 1 to 6  
rollD8()  // returns random number from 1 to 8  
rollD10()  // returns random number from 1 to 10 
rollD12()  // returns random number from 1 to 12  
rollD20()  // returns random number from 1 to 20  
rollD100()  // returns random number from 1 to 100  

Flip a Coin

flipACoin() // returns string "heads" or "tails"

If you need the number instead of strings, check anySidedDice() function.

Loaded Dice (cheat)

Loaded Dice function returns the value of a not fair dice. It receives 3 parameters:

  • number of sides: how many sides the dice to bo rolled has.
  • cheat level: how strong is the cheat factor. You can use any value from 0 to 1.
    • There are 3 pre-made strings you can use
    • "bard" for low-level cheat -"rogue" for medium-level cheat "mobster" for high-level cheat
  • desired value: the number you want to cheat.

Examples:

loadedDice(6,"bard",1) // rolls a 6 sided dice with a slightly higher chance of getting 1 as result.

loadedDice(10, 0.75, 7) // rolls a 10 sided dice with (75% + regular chance) of getting a 7. regular chance depends on dice size.

Any Sided Dice

A Dice function that receives any number as argument and rolls a dice with that many sides.

anySidedDice(42) // returns random number from 1 to 42  

Any Sided with Modifier

A Dice function that receives any number as first argument, rolls a dice with that many sides and add a modifier value.

anySidedDiceModifiers(20, 2) // returns random number from 1 to 20 and sums 2  

anySidedDiceModifiers(6, -1) // returns random number from 1 to 6 and detracts 1  

Many Dices

The equivalent to roll "4d8". Takes the number of dices as first argument and the dice side as second argument. Returns an array, first element is sum of roll and second element are the rolls itself.

manySidedDice(4, 8) // returns, for example: [[22],[8,7,2,5]]

Dice Bag

Receives as argument a string with how many dices you want to roll, using dice notation. Returns an array, first element is sum of roll and second element are the rolls itself.

diceBag(["d4", "d6", "d10", "d100"]) // returns, for example: [[74],[3,6,10,55]]

Roll and drop Minor Value

Receives two arguments, number of dices and second argument which dice sides. Make roll and deletes minor value. Returns an array with three elements, first is total roll after taking minor, second is full array without minor and third is minor value.

rollSetDeleteMinor(4,6) // rolls 4d6 and returns, for example: [[15],[6,6,3],[1]]

Roll and drop Major Value

Receives two arguments, number of dices and second argument which dice sides. Make roll and deletes major value. Returns an array with three elements, first is total roll after taking major, second is full array without major and third is major value.

rollSetDeleteMinor(4,6) // rolls 4d6 and returns, for example: [[10],[6,3,1],[6]]

Extras

Contact me on [email protected] or https://www.linkedin.com/in/carloscasciano/ if you need any help.