Giter VIP home page Giter VIP logo

dice_rolling's Introduction

Dice rolling

This module aims to implement the throw of many types of dice.

Installation

Simply run:

pip install dice-rolling

CLI usage

Once installed, a throw of a simple die of 6 sides can be performed with:

$ roll 1d6
Rolled 1d6 and got 4. [4]

Or, for instance, to throw three 20-sided dice can be as simple as:

$ roll 3d20
Rolled 3d20 and got 36. [14, 9, 13]

Module usage

To use this module you should use the class RollBuilder to implement the throws:

from dice_rolling import RollBuilder

builder = RollBuilder()
builder.set_amount_of_dice(3)
builder.set_number_of_sides(20)
builder.build()

print(builder.get_result())

Throws

The request must start with xdy, where x is the number of dice and y the number of faces of each die.

For example, to roll 4 6-sided dice:

$ roll 4d6
Rolled 4d6 and got 16. [5, 2, 3, 6]

After that, the following modifiers have been implemented (using the previous result as reference):

  • +a: Add the value of a to each die. For example, to roll 4 6-sided dice and add 3 to each roll:

    $ roll 4d6+3
    Rolled 4d6+3 and got 28. [8, 5, 6, 9]
  • khb: Keep the Highest b. For example, to roll 4 6-sided dice and keep the highest 2:

    $ roll 4d6kh2
    Rolled 4d6kh2 and got 11. Kept [5, 6] and discarded [3, 2].
  • klc: Keep the Lowest c. For example, to roll 4 6-sided dice and keep the lowest 2:

    $ roll 4d6kl2
    Rolled 4d6kl2 and got 5. Kept [2, 3] and discarded [5, 6].

Of course you can use together an addition with any of the keep actions:

$ roll 4d6+5kh2
Rolled 4d6+5kh2 and got 21. Kept [11, 10] and discarded [8, 7].

dice_rolling's People

Watchers

 avatar

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.