A Kotlin library to help you parse DiceNotations and roll dice for your RPG games.
Adding this library to your project is pretty simple, just add it to your gradle dependencies
:
repositories {
mavenCentral()
}
dependencies {
implementation("br.com.colman:dice-helper:version")
}
This library tries to implement a Dice Notation as it's commonly used. More use cases will be added as they're needed.
You can understand a little bit more of Dice Notation by reading this Wikipedia article.
Parse dice notation (currently only supports +
and -
)
val diceNotation: DiceNotation = "5d6 + 12 - 3d5".diceNotation()
Roll all dice/fixed values in a dice notation
val result: NotationRollResult = diceNotation.roll()
val total = result.total
val individualResults: List<DiceRollResult> = result.results
Roll a group of dice
// 15d10
val rollResult: List<Int> = RandomDice(amount = 15, maxFaceValue = 10).roll()
val total = rollResult.sum()
Please, feel free to create an issue or to open a pull request! I'll be glad to have your help :)