Skip to content

yyyaaaccc/dnd-dice-roller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Summary

roll.py logo
Roll the specified dice using commandline and return the result as a string.

Parameters

The dice parameter should be in the format 'NdS' where N is the number of dice to roll (defaulting to 1 if omitted) and S is the number of sides on each die.

If a numeric value is specified after the dice parameter (e.g. '2d6+3'), that value is added to the total roll value. The result string shows the total roll value followed by the added value. For example, '2d6+8' might return '2d6: 3+5+8 = 16'.

For example:

  • 'd20' rolls a 20-sided die once
  • '2d6' rolls two 6-sided dice and returns the sum of the results.
  • static value can be added to each rolled dice, e.g. 'd20+2'

Example usage and results

> python roll.py d20  
d20: 15 = 15
> python roll.py 1d100
1d100: 27 = 27
> python roll.py d20+4 2d6+0 d4+1 d1
d20+4:  6 (+4) = 10  
2d6+0:  4 + 4 = 8  
d4+1:   2 (+1) = 3   
d1:     1 = 1  

Releases

No releases published

Packages

No packages published

Languages