Skip to content

oganm/diceSyntax

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status codecov

diceSyntax

roll('d6') # roll d6
## [1] "Rolls: [ *6* ] (d6)"

## [1] 6
roll('4d6') # roll 4d6
## [1] "Rolls: [ 3 2 4 2 ] (4d6)"

## [1] 11
roll('4d6k3') # roll 4d6 keep 3 highest
## [1] "Rolls: [ 5 3 *6* ] (4d6k3)"
## [1] "Dropped: [ 2 ]"

## [1] 14
roll('4d6kl3') # roll 4d6 keep lowest 3
## [1] "Rolls: [ 3 *6* 2 ] (4d6kl3)"
## [1] "Dropped: [ *6* ]"

## [1] 11
roll('4d6d1') # roll 4d6 drop 1 lowest
## [1] "Rolls: [ *6* *6* *1* ] (4d6d1)"
## [1] "Dropped: [ *1* ]"

## [1] 13
roll('4d6dh1') # roll 4d6 drop highest 1
## [1] "Rolls: [ 4 2 4 ] (4d6dh1)"
## [1] "Dropped: [ 4 ]"

## [1] 10
roll('4d6+3') # roll 4d6 add 3
## [1] "Rolls: [ 3 *1* *6* 5 ] (4d6)"

## [1] 18
roll('4d6r1r2') # roll 4d6 reroll 1s and 2s
## [1] "Rolls: [ *6* *6* 4 5 ] (4d6r1r2)"

## [1] 21
roll('4d6r<2') # same as above
## [1] "Rolls: [ *6* *6* 4 *6* ] (4d6r<2)"

## [1] 22
roll('4d6r1ro2') # roll 4d6 reroll 1s but reroll 2s only once
## [1] "Rolls: [ 3 5 4 5 ] (4d6r1ro2)"

## [1] 17
roll('5d2!') # exploding dice
## [1] "Rolls: [ *1* *2* *1* *1* *2* *2* *1* *2* *1* ] (5d2!)"

## [1] 13
roll('5d2!!') # compounding dice
## [1] "Rolls: [ *1* *1* *1* *1* *1* ] (5d2!!)"

## [1] 5
roll('6d6+4d4-3d5') # multiple rolls
## [1] "Rolls: [ 5 2 2 3 3 5 ] (6d6)"
## [1] "Rolls: [ 3 3 *1* 2 ] (4d4)"
## [1] "Rolls: [ 3 *1* 3 ] (3d5)"

## [1] 22
r('1d6') # shortcut function
## [1] "Rolls: [ 4 ] (1d6)"

## [1] 4

Other variables that roll funciton accepts are

  • critMark: TRUE by default. If TRUE it adds stars around the dice roll in printed output if it is max or min value for the dice
  • vocal: TRUE by default. If FALSE disables printing of dice rolls
  • returnRolls: FALSE by default. If TRUE returns a list instead of an integer that includes rolled and dropped dice along with the dice sum
r("10d10dl3",returnRolls = TRUE, vocal = FALSE)
## $`10d10dl3`
## $`10d10dl3`$result
## [1] 54
## 
## $`10d10dl3`$dice
## [1]  6  7 10  7 10  7  7
## 
## $`10d10dl3`$drop
## [1] 2 3 3
## 
## 
## $result
## [1] 54

Dice stats

Probabilities of outcomes can be calculated with diceProb function

diceProb('4d6d1') %>% as.table %>% plot

diceProb('1d4!',explodeDepth = 4) %>% as.table %>% plot

diceProb('1d4ro1!',explodeDepth = 4) %>% as.table %>% plot

Releases

No releases published

Packages

No packages published

Languages