Giter VIP home page Giter VIP logo

dice-roller's Introduction

This project has a GUI where you set a list of n dice each with x sides then use mouse activity to generate randomness which is used to determine the rolls.

Description

This is a command line program for rolling dice.
The dice rolls are generated, in part, using your mouse movments to make it feel more like actually rolling dice.

How to use

The program takes in args in the following format <number>d<sides>[,<keep>][,<group_copies>]
<number> is the number of dice to roll
<sides> is the number of sides on the dice
<keep> is the number of dice to keep
<group_copies> is the number of times to roll the group of dice
You can pass in multiple dice groups at a time sperated by a space. ./cli_dice.exe 4d6 1d20

You can also use the -i flag to read in a yaml file to reroll the same dice from your previous roll.
Optionally you can lock in the values of some of the rolls.

Lets look at some examples:

You want to generate Ability Scores for a DnD character:

./cli_dice.exe 4d6,3,6
4d6 You want 4 six sided dice (This will be enough to calculate one ability score).
3 you only want to keep the values of the top 3 roles
6 you want 4d6,3 6 times for each ability score.
Your output would look like this:

┏━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━━━━━━━┓
┃ d6    ┃ roll ┃ k3 ┃ d6    ┃ roll ┃ k3 ┃ d6    ┃ roll ┃ k3 ┃ d6    ┃ roll ┃ k3 ┃ d6    ┃ roll ┃ k3 ┃ d6    ┃ roll ┃ k3 ┃ Total ┃ Keep Total ┃
┡━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━━━━━━━┩
│ 1     │ 4    │ -  │ 1     │ 1    │ -  │ 1     │ 2    │ -  │ 1     │ 6    │ -  │ 1     │ 4    │ -  │ 1     │ 5    │ -  │ 80    │ 70         │
│ 2     │ 2    │ -  │ 2     │ 6    │ -  │ 2     │ 2    │ -  │ 2     │ 3    │ -  │ 2     │ 2    │ -  │ 2     │ 6    │ -  │       │            │
│ 3     │ 4    │ -  │ 3     │ 1    │ -  │ 3     │ 1    │ -  │ 3     │ 2    │ -  │ 3     │ 2    │ -  │ 3     │ 3    │ -  │       │            │
│ 4     │ 5    │ -  │ 4     │ 5    │ -  │ 4     │ 5    │ -  │ 4     │ 5    │ -  │ 4     │ 2    │ -  │ 4     │ 2    │ -  │       │            │
│ Total │ 15   │ 13 │ Total │ 13   │ 12 │ Total │ 10   │ 9  │ Total │ 16   │ 14 │ Total │ 10   │ 8  │ Total │ 16   │ 14 │       │            │
└───────┴──────┴────┴───────┴──────┴────┴───────┴──────┴────┴───────┴──────┴────┴───────┴──────┴────┴───────┴──────┴────┴───────┴────────────┘

Netting you the following roll values:
13,12,9,14,8,14


You want to roll a d20 to see if you hit a target:

./cli_dice.exe 1d20
1d20 You want 1 twenty sided dice
Your output would look like this:

┏━━━━━━━┳━━━━━━┳━━━━┳━━━━━━━┳━━━━━━━━━━━━┓
┃ d20   ┃ roll ┃ k1 ┃ Total ┃ Keep Total ┃
┡━━━━━━━╇━━━━━━╇━━━━╇━━━━━━━╇━━━━━━━━━━━━┩
│ 1     │ 20   │ -  │ 20    │ 20         │
│ Total │ 20   │ 20 │       │            │
└───────┴──────┴────┴───────┴────────────┘

Yahtzee:

./cli_dice.exe 5d6
5d6 You want 5 six sided dice
Now lets say you want to keep the 3 highest rolls rerolling the other 2
Your first command generates a dice.yaml file that can be modified to lock in the dice you want to keep.
./cli_dice.exe -i dice.yaml will read in your previous rolls and only reroll the dice you didn't lock in.

Lets keep the 3 highest rolls by setting locked to true and reroll the other 2 dice
Update dice.yaml:

- dice:
  - 1_value: 1
    2_locked: false
  - 1_value: 3
    2_locked: false # Change me from false to true
  - 1_value: 4
    2_locked: false # Change me too
  - 1_value: 1
    2_locked: false
  - 1_value: 3
    2_locked: false # Change me too
  keep: 5
  sides: 6

After updating the dice you want to lock in to true reroll
./cli_dice.exe -i dice.yaml
After

- dice:
  - 1_value: 4
    2_locked: false
  - 1_value: 3
    2_locked: true
  - 1_value: 4
    2_locked: true
  - 1_value: 3
    2_locked: false
  - 1_value: 3
    2_locked: true
  keep: 5
  sides: 6

We went from: 1,3,4,1,3 to 4,3,4,3,3
You'll notice we retained the two 3s and one 4 from the previous roll and our two 1s rerolled into 3s.

Notes

Potential ideas for dice? https://stackoverflow.com/a/45226554

https://github.com/gsempe/diceware/wiki/Diceware-Password-Generator-How-It-Works

mouseCollector https://github.com/gsempe/diceware/blob/master/diceware-server/public/js/main.js#L141-L157

dice-roller's People

Contributors

jkluch avatar

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.