Giter Club home page Giter Club logo

ckdice's Introduction

ckDice

This is a little dice utility library with some convenience methods wrapped around a little dice function.

version

v1.0.0

installation

npm install ck-dice

The index.js file can be found in the src directory. This project is written in CoffeeScript.

walkthrough

When you require the library you get an instance of the DiceRoller class:

var diceRoller = require('ck-dice');

The main usage is the rollDice method. rollDice takes two parameters, the number of sides of the dice you want to roll and the number of dice you want rolled. You will get the sum of the number of dice rolled as a result. The next code example will roll four, six sided die.

var diceRoller = require('ck-dice');
console.log( diceRoller.rollDice(6, 4);
// result: 13

If you want to get an array of rolled dice back you can use the rollList function. This function also takes the number of sides and the number of dice as parameters and returns an array of integers.

var diceRoller = require('ck-dice');
console.log( diceRoller.rollList(10, 10);
// result: [ 4, 8, 3, 1, 6, 9, 2, 9, 3, 9 ]

There are also 9 convenience methods on the object representing the standard dice you could use. These methods take the number of dice and return a integer representing the sum the of the rolls. The methods area called as follows:

  1. d2()
  2. d4()
  3. d6()
  4. d8()
  5. d10()
  6. d12()
  7. d18()
  8. d20()
  9. d100()

Conclusion

If you find a bug or want to add some features, let me know. This project is still under active development.

ckdice's People

Watchers

James Cloos avatar Baudin999 avatar

ckdice's Issues

Roll Parser

It should be possible to parse string with dicified calculations:

4d12 + 12 should resolve in a function calling rollDice(12, 4) + 12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.