Add DiceServ: dice-roll and math-expression service

A stateless service for tabletop games over IRC. ROLL/CALC evaluate a dice
+ math expression (ROLL rounds to a whole number, CALC keeps decimals);
EXROLL/EXCALC also show each die. Supports NdM / dM / d% dice, + - * / ^ %,
parentheses, implicit multiplication, unary minus, pi/e, a set of functions
(sqrt, floor, sin, min, …), and N~expr to repeat a roll.

Modernises the C++ original: it ships its own Mersenne-Twister RNG in C
and parses via shunting-yard with a variadic-argument hack; this is a
typed AST from a small recursive-descent parser plus the rand crate —
shorter, and the dice/sides/total caps make abuse (999999d6) a clean error
instead of a hang. Opt-in (add "diceserv" to [modules].services).
This commit is contained in:
Jean Chevronnet 2026-07-14 03:46:34 +00:00
parent 3f8649414f
commit 1e8a5eab36
No known key found for this signature in database
6 changed files with 528 additions and 1 deletions

9
diceserv/Cargo.toml Normal file
View file

@ -0,0 +1,9 @@
[package]
name = "fedserv-diceserv"
version = "0.0.1"
edition = "2021"
description = "DiceServ: a dice-roll and math-expression service for tabletop games over IRC."
[dependencies]
fedserv-api = { path = "../api" }
rand = "0.8"