mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #8489] [Issue]: Unify dice rolling and notation parsing services #8375
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8375
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpicyMarinara on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8489
Originally assigned to: @kolacheee on GitHub.
Summary
Dice rolling and notation parsing are currently distributed across multiple generators, RNG implementations, and parsers. Consolidating them into a shared service could improve maintainability, consistency, and support for extension-defined dice formats such as those needed by a Genesys extension.
Expected behavior
A shared dice service should consistently handle supported dice rolls and parsing across the application, while allowing extensions to register or provide custom dice formats and rolling behavior.
Actual behavior
Dice rolls currently use multiple implementations, including Math.random(), crypto.randomInt, seeded mulberry32, inline random logic, and macro-specific behavior. Dice notation is handled by at least seven separate parsers or formatters, resulting in duplicated and potentially inconsistent behavior.
Steps to reproduce
Environment
Logs, screenshots, or video
No logs, screenshots, or video provided. The Discord context includes a code-path inventory for the current dice rolling and parsing implementations.
Additional context
Current rolling mechanisms include rollParsedDice using Math.random(), an independent skill-check d20 implementation, inline Math.random() calls, crypto.randomInt through rollDieSecurely, seeded mulberry32 for ruleset combat, and macro-specific seeded or Math.random() behavior. The reported paths include shared/src/utils/dice-notation.ts, shared/src/utils/macro-engine.ts, server/src/services/game/, server/src/services/multiplayer/player-commands.ts, server/src/services/tools/tool-executor.ts, shared/src/features/ruleset-combat/, and related client parsers and formatters. The request is an architectural feature proposal rather than a report of a specific runtime error.
Discord thread: Unified Dice Rolling Service
Discord thread link: https://discord.com/channels/1417099416812392641/1565533348716089424
Requested by: ylliselmanii (ylliselmanii, Discord ID 177503556272783360)
Discord thread transcript (4 messages)
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Oct 30, 2026):
Thanks for mapping all of this out. A shared dice service sounds good to us, and we'd be glad to see extension-defined formats. We have a large Game Mode / ruleset-combat branch in progress that touches several of the listed paths, so a few requests to keep the two from colliding:
rulesetCombatRoller(seed, cursor)is deliberate: a fight replays from its seed plus the choices made, and the combat director, item use, loot and markets rely on that cursor. A unified service should accept an injected roller (seeded stream or test sequence) rather than swap those paths toMath.random()orcrypto.randomInt.rollDieSecurelyon purpose for player-facing rolls; please keep that behaviour, just routed through the shared service.sides-only fields inruleset.schema.tsand the baredMreading inlive-state.tsare part of the published ruleset API that installed rulesets depend on. Any new notation should be additive and behind a new API version, with old rulesets reading exactly as before.shared/src/features/ruleset-combat/,ruleset-combat-director.service.ts) could come last, or be left on its existing roller behind the new interface, that would help a lot.Happy to review the ruleset-combat part when it's up.
@kolacheee commented on GitHub (Oct 30, 2026):
#8495 covers the first part (one roller shape, secure plain rolls,
{{roll:}}and the narration badge on the shared grammar). Before building the extension-format part, here's the plan, so the Genesys use case lands where it works best:symbol-poolruleset (Capability API 1.141, fights since #8220) declares its own dice, faces and symbols; the Engine throws them for checks and fights, cancels symbols and spends leftovers. So a Genesys system is best shipped as a ruleset, with no extension needed for the rules themselves.symbol-pool,/roll, composer dice and theroll_dicetool also accept its dice by name (for example2 ability 1 proficiency vs 2 difficulty) and report the symbols, rolled with the shared secure roller. No ruleset schema change.marinara.dice.registerFormat({ id, label, parse, roll })for Personal Extensions, whererollreceives the host's die roller so an extension can't choose its own faces. Personal Extensions run in the browser, so this covers/rolland the composer; server-side rolls (the GM's tool) stay on the shared grammar and ruleset dice. Does that boundary sound right to you?Ruleset combat moves onto the shared roller interface last, keeping its seed + cursor stream.