[PR #6418] [MERGED] Support situational modifiers and DC in Roleplay dice commands #7169

Closed
opened 2026-10-23 04:17:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6418
Author: @SpicyMarinara
Created: 9/20/2026
Status: ✅ Merged
Merged: 9/20/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/roleplay-roll-modifiers


📝 Commits (2)

  • c924b2a chore: start roleplay roll modifiers and DC (#6417)
  • ca2c9e1 feat(roleplay): support situational roll modifiers and DC (#6417)

📊 Changes

12 files changed (+186 additions, -24 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/roleplay-commands.e2e.ts (+41 -16)
📝 packages/client/src/components/dice/AnimatedDiceRoll.tsx (+10 -1)
📝 packages/client/src/lib/dice-roll-result.ts (+2 -1)
📝 packages/server/src/routes/generate.routes.ts (+4 -0)
📝 packages/server/src/services/game/dice.service.ts (+3 -1)
📝 packages/server/src/services/generation/roleplay-commands.ts (+9 -1)
📝 packages/server/src/services/tools/tool-executor.ts (+12 -2)
📝 packages/shared/src/features/function-calls/tools/roll-dice/manifest.ts (+13 -0)
📝 packages/shared/src/types/game.ts (+2 -0)
📝 packages/shared/src/types/roleplay-command.ts (+9 -1)
📝 scripts/regressions/roleplay-commands.regression.ts (+79 -1)

📄 Description

Linked issue

Closes #6417

Why this change

Roleplay can now account for helpful equipment or adverse conditions and declare the difficulty before rolling. For example, the Narrator can roll for Mari with modifier: 2 for a lockpick or modifier: -2 for a downpour, plus an optional dc.

What changed

  • Add optional integer modifier and dc to the existing roll_dice JSON schema and textual Roleplay command. Reuse the executor to add the situational adjustment once, alongside notation and automatic attribute bonuses, and return whether the total meets the DC.
  • Preserve the fields in command/result metadata and display DC on the existing animated dice card, using the existing translated label. Older commands keep their existing result shape.
  • Add one short sentence to the prompt: “Optional modifier adds a situational bonus/penalty once; dc sets the total needed to succeed.”
  • Extend the existing Node and browser regressions; no dependencies, settings, new resolver, or new animation.

Validation

Passed locally: pnpm install, pnpm check (including localization and production build), pnpm regression:prompt, and the Roleplay command, dice notation, Game dice tool, and dice display regressions. The production Docker image built and served both /api/health and the frontend successfully.

The focused browser matrix passed all 12 cases across desktop Chromium, mobile Chromium, and mobile WebKit, with light/dark display, native/textual commands, Narrator targeting both persona formats, saved command/result fields, reload and translation-only rendering. Screenshots were inspected for DC readability and card fit. These flows use a local scripted provider with the real Engine API, stream, random dice and persistence; they do not claim external-model or physical-phone testing.

Local CodeRabbit review completed. Its one trivial suggestion concerned the pre-existing fallback from a nonnumeric result modifier to zero in parseRollDiceToolResult. That behavior is unchanged, the executor emits a numeric modifier, and changing legacy result parsing is outside this feature; the new optional DC is strictly validated. No substantive findings remain.

  • 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

Manual verification notes

  • Manually verify a Roleplay roll for the persona with a positive modifier, negative modifier, and DC using a preferred model, including reload and mobile display.
  • Manually verify commands omitting the new fields retain their existing behavior.

Claim boundary

Prompt/tool request shaping and persisted optional result fields are the risk boundary. Deterministic tests fix only the random face and exercise positive/negative/zero adjustments, assigned attributes, notation bonuses, participants without stats, equality at the DC, failure below it, omitted fields, malformed values, and unsafe totals. Browser assertions check the model's real tool result against the saved result and displayed total. No storage migration is needed.

Docs and release impact

User-focused Unreleased changelog entry added. No version bump, install/update change, or user-guide edits.

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

UI evidence (if applicable)

Proof, screenshots and logs. The before image is the actual staging dice card from #6396's proof; after images are from this PR's passing run.

Summary by CodeRabbit

  • New Features

    • Roleplay dice commands now support optional situational bonuses or penalties.
    • Commands can specify a difficulty class (DC), with results indicating whether the roll succeeds.
    • Dice cards display the DC alongside the roll details.
    • Situational modifiers combine with existing attribute and notation bonuses.
  • Bug Fixes

    • Invalid modifier and DC values are rejected instead of producing unreliable results.

🔄 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/6418 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/20/2026 **Status:** ✅ Merged **Merged:** 9/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/roleplay-roll-modifiers` --- ### 📝 Commits (2) - [`c924b2a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c924b2aa42bde043fa9aa975cea8b24937cd017d) chore: start roleplay roll modifiers and DC (#6417) - [`ca2c9e1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ca2c9e128d7bbecd3ea3e88f762d725b89915e28) feat(roleplay): support situational roll modifiers and DC (#6417) ### 📊 Changes **12 files changed** (+186 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/roleplay-commands.e2e.ts` (+41 -16) 📝 `packages/client/src/components/dice/AnimatedDiceRoll.tsx` (+10 -1) 📝 `packages/client/src/lib/dice-roll-result.ts` (+2 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+4 -0) 📝 `packages/server/src/services/game/dice.service.ts` (+3 -1) 📝 `packages/server/src/services/generation/roleplay-commands.ts` (+9 -1) 📝 `packages/server/src/services/tools/tool-executor.ts` (+12 -2) 📝 `packages/shared/src/features/function-calls/tools/roll-dice/manifest.ts` (+13 -0) 📝 `packages/shared/src/types/game.ts` (+2 -0) 📝 `packages/shared/src/types/roleplay-command.ts` (+9 -1) 📝 `scripts/regressions/roleplay-commands.regression.ts` (+79 -1) </details> ### 📄 Description ## Linked issue Closes #6417 ## Why this change Roleplay can now account for helpful equipment or adverse conditions and declare the difficulty before rolling. For example, the Narrator can roll for Mari with `modifier: 2` for a lockpick or `modifier: -2` for a downpour, plus an optional `dc`. ## What changed - Add optional integer `modifier` and `dc` to the existing `roll_dice` JSON schema and textual Roleplay command. Reuse the executor to add the situational adjustment once, alongside notation and automatic attribute bonuses, and return whether the total meets the DC. - Preserve the fields in command/result metadata and display DC on the existing animated dice card, using the existing translated label. Older commands keep their existing result shape. - Add one short sentence to the prompt: “Optional modifier adds a situational bonus/penalty once; dc sets the total needed to succeed.” - Extend the existing Node and browser regressions; no dependencies, settings, new resolver, or new animation. ## Validation Passed locally: `pnpm install`, `pnpm check` (including localization and production build), `pnpm regression:prompt`, and the Roleplay command, dice notation, Game dice tool, and dice display regressions. The production Docker image built and served both `/api/health` and the frontend successfully. The focused browser matrix passed all 12 cases across desktop Chromium, mobile Chromium, and mobile WebKit, with light/dark display, native/textual commands, Narrator targeting both persona formats, saved command/result fields, reload and translation-only rendering. Screenshots were inspected for DC readability and card fit. These flows use a local scripted provider with the real Engine API, stream, random dice and persistence; they do not claim external-model or physical-phone testing. Local CodeRabbit review completed. Its one trivial suggestion concerned the pre-existing fallback from a nonnumeric result modifier to zero in `parseRollDiceToolResult`. That behavior is unchanged, the executor emits a numeric modifier, and changing legacy result parsing is outside this feature; the new optional DC is strictly validated. No substantive findings remain. - [ ] `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` ### Manual verification notes - Manually verify a Roleplay roll for the persona with a positive modifier, negative modifier, and DC using a preferred model, including reload and mobile display. - Manually verify commands omitting the new fields retain their existing behavior. ### Claim boundary Prompt/tool request shaping and persisted optional result fields are the risk boundary. Deterministic tests fix only the random face and exercise positive/negative/zero adjustments, assigned attributes, notation bonuses, participants without stats, equality at the DC, failure below it, omitted fields, malformed values, and unsafe totals. Browser assertions check the model's real tool result against the saved result and displayed total. No storage migration is needed. ## Docs and release impact User-focused Unreleased changelog entry added. No version bump, install/update change, or user-guide edits. - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) [Proof, screenshots and logs](https://gist.github.com/SpicyMarinara/8e3b803325c83ff2cb51c8b98d534816). The before image is the actual staging dice card from #6396's proof; after images are from this PR's passing run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Roleplay dice commands now support optional situational bonuses or penalties. * Commands can specify a difficulty class (DC), with results indicating whether the roll succeeds. * Dice cards display the DC alongside the roll details. * Situational modifiers combine with existing attribute and notation bonuses. * **Bug Fixes** * Invalid modifier and DC values are rejected instead of producing unreliable results. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:17:10 +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#7169
No description provided.