mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #593] [MERGED] fix(game,combat): apply sheet attribute modifiers to skill checks and combat init #4688
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#4688
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/593
Author: @Romuromylus
Created: 5/9/2026
Status: ✅ Merged
Merged: 5/9/2026
Merged by: @Romuromylus
Base:
main← Head:fix/game-mode-skill-check-attributes📝 Commits (2)
1c400b7fix(game,combat): apply sheet attribute modifiers to skill checks and combat initab5082efix(combat): guard chat.metadata JSON.parse in encounter init📊 Changes
9 files changed (+183 additions, -26 deletions)
View changed files
📝
packages/client/src/components/game/GameCharacterSheet.tsx(+9 -0)📝
packages/client/src/components/game/GameSurface.tsx(+1 -0)📝
packages/client/src/hooks/use-game.ts(+8 -2)📝
packages/client/src/lib/game-tag-parser.ts(+15 -0)📝
packages/server/src/routes/encounter.routes.ts(+42 -1)📝
packages/server/src/routes/game.routes.ts(+27 -6)📝
packages/server/src/services/game/gm-prompts.ts(+2 -2)📝
packages/server/src/services/game/skill-check.service.ts(+61 -9)📝
packages/server/test/game-session-prompts.test.ts(+18 -6)📄 Description
Linked issue
Closes #592
Why this change
rolls/modifier/total/resultitself, and the deterministic server resolver almost never ran. SettingSTR 20on the sheet made no difference to a Strength check outcome.playerStats.attributeswhich isnullfor every chat. The LLM generatedattack/defense/hpwith no link to the player's intended build.PlayerStats.attributesis initialised tonullin every game-state writer and never seeded; the GM prompt asked the AI to fill in roll math; and the sheet's free-formArray<{name,value}>shape never had a mapper to the strictRPGAttributes: { str, dex, con, int, wis, cha }shape the engine wants.What changed
packages/client/src/components/game/GameCharacterSheet.tsx): show the D&D-style modifier next to each attribute on the read-only grid (STR 17 (+3)), using the samefloor((score - 10) / 2)formula the server already implements for skill checks.packages/server/src/services/game/skill-check.service.ts): addedmapSheetAttributesToRPG— case-insensitive map fromArray<{name,value}>(sheet shape; acceptsSTR/Str/Strength,DEX/Dexterity, etc.) toPartial<RPGAttributes>. Custom names are dropped.packages/server/src/routes/game.routes.ts): whenplayerStats.attributesis null, falls back to mapping the player'sgameCharacterCards[0].rpgStats.attributesfrom chat metadata. No DB migration; existing chats benefit immediately. Schema now also acceptspreRolledD20: 1-20so a player-submitted[dice:1d20]can be applied through the same modifier-aware code path.resolveSkillCheck(packages/server/src/services/game/skill-check.service.ts): honourspreRolledD20— when present, skips internal d20 rolling and uses the player's number as theusedRoll, with the attribute modifier applied on top.packages/server/src/services/game/gm-prompts.ts): emits sparse[skill_check: skill="..." dc="..."](or…rolls="<player's d20>"after a player pre-roll). The instruction is explicit that the engine fills in modifier/total/result; do not invent them. The client atcomponents/game/GameSurface.tsxalready had a fallback path to call/skill-checkwhen those fields are absent — this PR turns that fallback into the primary path.packages/client/src/lib/game-tag-parser.ts): when a sparse tag carries a single integer inrolls=, surfaces it aspreRolledD20on the parsed tag so the client mutation forwards it to the server.packages/server/src/routes/encounter.routes.ts): same lazy fallback — whenplayerStats.attributesis null, reads the player's character-sheet attributes from chat metadata and emits aCharacter Sheet Attributes: STR x, DEX y, ...line in the encounter context. Adds a one-line prompt note instructing the LLM to scale generatedattack/defense/hp(when not configured) by attribute values on a 10-as-average baseline. Configured Max HP still wins.packages/server/test/game-session-prompts.test.ts): updated theskill_checkformat-reminder assertions for both the AI-initiated and player-prerolled prompt shapes; added a case for the player-prerolled branch.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
(+N)/(−N)modifier underneath each attribute value in the read-only Attributes grid, matchingfloor((score - 10) / 2).STR 20resolves with a noticeably higher success rate / final total than the same character withSTR 1.rolls/modifier/total/resultnumbers — the resolved skill-check popup should reflect the server-rolled d20 plus the deterministic attribute modifier.[dice:1d20]first, then take an action; the resolved roll should equal your d20 plus the sheet's attribute modifier.[state: combat]from the GM and confirm the generated party member'sattack/defense/hpreflects the character's RPG attributes (high STR → noticeably higher attack power; high DEX → higher speed).0), with no broken state.playerStats.attributes = nulland no migration is needed — the lazy fallback should still pick up the sheet attributes.Docs and release impact
UI evidence (if applicable)
The read-only attribute grid in
GameCharacterSheetnow renders a third row under each value:Summary by CodeRabbit
New Features
Improvements
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.