https://github.com/leocolman/dice-helper
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.
https://github.com/leocolman/dice-helper
dice dice-roller rpg
Last synced: 5 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/leocolman/dice-helper
- Owner: LeoColman
- License: apache-2.0
- Created: 2021-05-28T12:14:08.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T20:25:39.000Z (over 2 years ago)
- Last Synced: 2024-05-01T16:48:46.487Z (about 2 years ago)
- Topics: dice, dice-roller, rpg
- Language: Java
- Homepage:
- Size: 108 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dice Helper
[](https://github.com/LeoColman/dice-helper/actions/workflows/build.yml)
[](https://github.com/LeoColman/dice-helper/blob/master/LICENSE)

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`:
```kotlin
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](https://en.wikipedia.org/wiki/Dice_notation).
# Features
Parse dice notation (currently only supports `+` and `-`)
```kotlin
val diceNotation: DiceNotation = "5d6 + 12 - 3d5".diceNotation()
```
Roll all dice/fixed values in a dice notation
```kotlin
val result: NotationRollResult = diceNotation.roll()
val total = result.total
val individualResults: List = result.results
```
Roll a group of dice
```kotlin
// 15d10
val rollResult: List = 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 :)