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
Cargo.lock generated
View file

@ -328,6 +328,7 @@ dependencies = [
"fedserv-api",
"fedserv-botserv",
"fedserv-chanserv",
"fedserv-diceserv",
"fedserv-example",
"fedserv-hostserv",
"fedserv-inspircd",
@ -372,6 +373,14 @@ dependencies = [
"fedserv-api",
]
[[package]]
name = "fedserv-diceserv"
version = "0.0.1"
dependencies = [
"fedserv-api",
"rand",
]
[[package]]
name = "fedserv-example"
version = "0.0.1"