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.
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
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.
- With success check:
- Basic roll (バラバラロール, B):
nBx
- With success check:
xBn>=y
etc.
- With success check:
- Exploding roll (個数振り足しロール, R):
xRn>=y
etc. - Compounding roll (上方無限ロール, U):
xUn[t]
- With success check:
xUn[t]>=y
etc.
- With success check:
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 available in dice rolling and calculation are listed.
In arithmetic operations, a numerical value is treated as an integer.
- Unary operators
- Unary plus (noop)
+
- Unary minus (sign inversion)
-
- Unary plus (noop)
- Binary operators
- Add
+
- Subtract
-
- Multiply
*
- Divide
- Divide with rounding down
/
- Divide with rounding
/R
- Divide with rounding up
/U
- Divide with rounding down
- Add
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
>=
Original BCDice authors are Faceless and Taitai Takeru (たいたい竹流).