[PR #8497] [MERGED] Keep or drop dice in a roll: 4d6kh3, 2d20kl1, 4d6dl1 (part 2 of #8489) #8636

Closed
opened 2026-11-07 16:46:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8497
Author: @kolacheee
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @kolacheee

Base: staging ← Head: claude/project-thread-mhcusi


📝 Commits (5)

  • 6d9b96b Keep or drop dice in a pool: 4d6kh3, 2d20kl1, 4d6dl1
  • 9c611f1 Explain keep and drop in the /roll docs
  • b6a2af2 Let the composer dice route take a pool, and refuse an oversized one
  • 90f03eb Merge remote-tracking branch 'origin/staging' into claude/project-thread-mhcusi
  • 252ae99 Refuse an oversized pool in the composer route's schema

📊 Changes

13 files changed (+262 additions, -36 deletions)

View changed files

📝 docs/chats/slash-commands.md (+2 -0)
📝 packages/client/src/components/dice/AnimatedDiceRoll.tsx (+8 -4)
📝 packages/client/src/lib/dice-roll-result.ts (+2 -0)
📝 packages/client/src/lib/slash-commands.ts (+10 -6)
📝 packages/server/src/routes/game.routes.ts (+2 -2)
📝 packages/server/src/services/game/dice.service.ts (+34 -4)
📝 packages/server/src/services/generation/roleplay-rolls.ts (+3 -3)
📝 packages/server/src/services/multiplayer/player-commands.ts (+6 -3)
📝 packages/server/src/services/tools/tool-executor.ts (+10 -7)
📝 packages/shared/src/features/function-calls/tools/roll-dice/manifest.ts (+4 -1)
📝 packages/shared/src/types/game.ts (+3 -0)
📝 packages/shared/src/utils/dice-notation.ts (+93 -5)
📝 scripts/regressions/dice-notation.regression.ts (+85 -1)

📄 Description

Linked issue

Part of #8489. It follows #8495 and builds the dice pool model the issue's submitter described: a roll is a pool of dice, each die's face is fixed once thrown, and keep, drop and modifiers act on the pool rather than on the faces.

Why this change

Tabletop rollers read 4d6kh3 (roll four, keep the highest three) and 2d20kl1 (disadvantage), but every Marinara roller refused anything past NdM+K. Each roller would otherwise grow its own keep logic, which is the duplication #8489 asks us to remove.

What changed

  • /roll, composer dice, the roll_dice tool, multiplayer /roll and Roleplay [roll:] commands accept keep and drop: kh/k (keep highest), kl (keep lowest), dl (drop lowest), dh (drop highest), with an optional modifier after it (4d6kh3+2).
  • Every face is still shown as it fell. Only the kept dice count toward the total, the dice card dims the dropped ones and adds only the kept ones, and text results strike them through (3, 6, ~~1~~, 5).
  • A keep that leaves no dice, or keeps more dice than were thrown (4d6kh0, 2d20kh3, 4d6dl4), is refused like any other invalid notation.
  • Readers that only take NdM (ruleset sheets, the GM's [dice:] and [skill_check:] tags, {{roll:}}) are unchanged.
  • For developers: parseDicePool (in @marinara-engine/shared) is the pool reader the plain rollers use. A parsed notation can carry keep, a rolled result can carry kept (the places of the counted dice), and keptDice, formatKeptRolls and isKeptDice are shared helpers.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

pnpm check ran clean locally before the rebase onto current staging. These regressions pass after the rebase: dice-notation, with new cases for the pool grammar, refusals, tie-breaking, the clamp, and the tool, composer and /roll paths. Also run and passing: dice-display, game-dice-commands, game-mode-dice-tool, game-text-dice, roleplay-commands, game-tool-controls, one-request-dice-placeholders and -prompt, prompt, roleplay-roll-helpers, roleplay-function-calling, game-ruleset-checks, and the other roll_dice regressions.

Manual verification notes

  • Manually verify /roll 4d6kh3 posts a card with four dice, one dimmed, and a total of the three kept.
  • Manually verify /roll 2d20kl1+3 keeps the lower die.
  • Manually verify /roll 4d6kh0 shows "Invalid dice notation".

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/chats/slash-commands.md gains one paragraph on keep and drop; it is added to the docs-i18n catch-up issue #8499.

UI evidence (if applicable)

The dice card reuses its existing dimming for dice that didn't count, so there's no new layout.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8497 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `claude/project-thread-mhcusi` --- ### 📝 Commits (5) - [`6d9b96b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d9b96bfdf88e8bc32429b3c7937aeb2fd067821) Keep or drop dice in a pool: 4d6kh3, 2d20kl1, 4d6dl1 - [`9c611f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9c611f17e88ea139f76fa0493040037c97f8cf53) Explain keep and drop in the /roll docs - [`b6a2af2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b6a2af2c92a9617fd13e64a20aad3872ec4edfa3) Let the composer dice route take a pool, and refuse an oversized one - [`90f03eb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90f03eb6dd4f6aad33ced83ad71b260031c6059b) Merge remote-tracking branch 'origin/staging' into claude/project-thread-mhcusi - [`252ae99`](https://github.com/Pasta-Devs/Marinara-Engine/commit/252ae99b68eeaf3f04995af1d479c676e86ef8f3) Refuse an oversized pool in the composer route's schema ### 📊 Changes **13 files changed** (+262 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `docs/chats/slash-commands.md` (+2 -0) 📝 `packages/client/src/components/dice/AnimatedDiceRoll.tsx` (+8 -4) 📝 `packages/client/src/lib/dice-roll-result.ts` (+2 -0) 📝 `packages/client/src/lib/slash-commands.ts` (+10 -6) 📝 `packages/server/src/routes/game.routes.ts` (+2 -2) 📝 `packages/server/src/services/game/dice.service.ts` (+34 -4) 📝 `packages/server/src/services/generation/roleplay-rolls.ts` (+3 -3) 📝 `packages/server/src/services/multiplayer/player-commands.ts` (+6 -3) 📝 `packages/server/src/services/tools/tool-executor.ts` (+10 -7) 📝 `packages/shared/src/features/function-calls/tools/roll-dice/manifest.ts` (+4 -1) 📝 `packages/shared/src/types/game.ts` (+3 -0) 📝 `packages/shared/src/utils/dice-notation.ts` (+93 -5) 📝 `scripts/regressions/dice-notation.regression.ts` (+85 -1) </details> ### 📄 Description ## Linked issue Part of #8489. It follows #8495 and builds the dice pool model the issue's submitter described: a roll is a pool of dice, each die's face is fixed once thrown, and keep, drop and modifiers act on the pool rather than on the faces. ## Why this change Tabletop rollers read `4d6kh3` (roll four, keep the highest three) and `2d20kl1` (disadvantage), but every Marinara roller refused anything past `NdM+K`. Each roller would otherwise grow its own keep logic, which is the duplication #8489 asks us to remove. ## What changed - `/roll`, composer dice, the `roll_dice` tool, multiplayer `/roll` and Roleplay `[roll:]` commands accept keep and drop: `kh`/`k` (keep highest), `kl` (keep lowest), `dl` (drop lowest), `dh` (drop highest), with an optional modifier after it (`4d6kh3+2`). - Every face is still shown as it fell. Only the kept dice count toward the total, the dice card dims the dropped ones and adds only the kept ones, and text results strike them through (`3, 6, ~~1~~, 5`). - A keep that leaves no dice, or keeps more dice than were thrown (`4d6kh0`, `2d20kh3`, `4d6dl4`), is refused like any other invalid notation. - Readers that only take `NdM` (ruleset sheets, the GM's `[dice:]` and `[skill_check:]` tags, `{{roll:}}`) are unchanged. - For developers: `parseDicePool` (in `@marinara-engine/shared`) is the pool reader the plain rollers use. A parsed notation can carry `keep`, a rolled result can carry `kept` (the places of the counted dice), and `keptDice`, `formatKeptRolls` and `isKeptDice` are shared helpers. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` `pnpm check` ran clean locally before the rebase onto current staging. These regressions pass after the rebase: dice-notation, with new cases for the pool grammar, refusals, tie-breaking, the clamp, and the tool, composer and `/roll` paths. Also run and passing: dice-display, game-dice-commands, game-mode-dice-tool, game-text-dice, roleplay-commands, game-tool-controls, one-request-dice-placeholders and -prompt, prompt, roleplay-roll-helpers, roleplay-function-calling, game-ruleset-checks, and the other `roll_dice` regressions. ### Manual verification notes - Manually verify `/roll 4d6kh3` posts a card with four dice, one dimmed, and a total of the three kept. - Manually verify `/roll 2d20kl1+3` keeps the lower die. - Manually verify `/roll 4d6kh0` shows "Invalid dice notation". ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/chats/slash-commands.md` gains one paragraph on keep and drop; it is added to the docs-i18n catch-up issue #8499. ## UI evidence (if applicable) The dice card reuses its existing dimming for dice that didn't count, so there's no new layout. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:46:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8636
No description provided.