diceRolls

package module
v0.0.0-...-6938628 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 6 Imported by: 0

README

Dice rolling

Simple dice rolling library.

Usage

The main entrypoint to the library is the diceRolls.Parse function:

func Parser(expression string) (Result, error)

Result has to methods:

  • Result.Value() int - evaluate parsed expression and roll dices. Dice are rolled on each call.
  • Result.Description(detailed bool) string - return string representation of expression. If detailed == true it will include dice results in square brackets.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result interface {
	Value() int
	Description(bool) string
}

func Parser

func Parser(expression string) (Result, error)

func RollDiceNotation

func RollDiceNotation(notation string) (Result, error)

func RollSimpleDice

func RollSimpleDice(n, k int) (Result, error)

RollSimpleDice rolls k-side dice n times and return sum of result If times is negative returns error If sides is negative returns error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL