Skip to content

LeoColman/dice-helper

Repository files navigation

Dice Helper

Build GitHub Maven Central

A Kotlin library to help you parse DiceNotations and roll dice for your RPG games.

Using

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")
}

Dice Notation

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.

Features

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()

Contributing

Please, feel free to create an issue or to open a pull request! I'll be glad to have your help :)

About

RPG dice helper written in Kotlin for Kotlin. The dice helper assists with parsing dice notation and rolling different dice for all kinds of RPG systems.

Topics

Resources

License

Stars

Watchers

Forks