Skip to content

raa0121/GoBCDice

Repository files navigation

GoBCDice

Build Status Build status codecov

GoBCDice is a Go implementation of BCDice, a dice bot for tabletop RPGs supporting many Japanese game systems. It will consist of the core dice roller (dice notation parser and evaluator) and many game-system-specific dice bots.

Usage

Prerequisite: Go ≥ 1.12

Currently, only the REPL of GoBCDice can be built and run.

cd cmd/GoBCDiceREPL

# Build REPL
go build

# Run REPL
./GoBCDiceREPL

To modify and build the dice notation parser (pkg/core/parser/parser.go), you also need to install github.com/mna/pigeon first:

GO111MODULE=off go get -u github.com/mna/pigeon

And then build it with the following commands:

cd pkg/core/parser
make

Core dice roller

The core dice roller of GoBCDice provides the common dice rolling feature.

BCDice supports the following dice notations (the detailed description can be found at bcdice/BCDice/docs/README.txt on GitHub). The notations currently supported by GoBCDice are checked.

  • Sum roll (加算ロール, D): xDn
    • With success check: xDn>=y etc.
  • Basic roll (バラバラロール, B): nBx
    • With success check: xBn>=y etc.
  • Exploding roll (個数振り足しロール, R): xRn>=y etc.
  • Compounding roll (上方無限ロール, U): xUn[t]
    • With success check: xUn[t]>=y etc.

x: number of dice, n: sides of die, y: target number, t: threshold for rerolling dice.

The optional syntaxes are as follows:

  • Embedding random number: [min...max]
  • Secret roll: SxDn etc.

The core dice roller also supports the following commands:

  • Calculation (arithmetic operation, C): C(1+2-3*4/5) etc.
  • Random sampling (choice): CHOICE[A,B,C] etc.

Operators

Operators available in dice rolling and calculation are listed.

Arithmetic operators

In arithmetic operations, a numerical value is treated as an integer.

  • Unary operators
    • Unary plus (noop) +
    • Unary minus (sign inversion) -
  • Binary operators
    • Add +
    • Subtract -
    • Multiply *
    • Divide
      • Divide with rounding down /
      • Divide with rounding /R
      • Divide with rounding up /U

Comparison operators

Comparison operators are used for a success check.

  • Equal to =
  • Not equal to <>
  • Less than <
  • Less than or equal to <=
  • Greater than >
  • Greater than or equal to >=

Author

raa0121

Original BCDice authors are Faceless and Taitai Takeru (たいたい竹流).

About

GoBCDice is BCDice reimplemented by Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages