mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6382] [MERGED] feat(game): the combat director resolves a ruleset fight on its own ledger (real combat C3a, server half) #7156
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#7156
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/6382
Author: @kolacheee
Created: 9/19/2026
Status: ✅ Merged
Merged: 9/19/2026
Merged by: @kolacheee
Base:
staging← Head:feat/ruleset-combat-director📝 Commits (10+)
61634f8feat(game): the ruleset fight shares its target rule, and the director contract learns a third style62687cafeat(game): the director resolves a ruleset fight on its own ledger645710cfeat(game): the Game Master picks a ruleset fight's candidate from the ruleset's own numbers0cb9437feat(game): the encounter blueprint asks for opponents in the ruleset's own terms46f2772test(game): the ruleset fight is driven with no database, on both example rulesets78a3a18test(game): the ruleset fight runs through the real routes, with its sheets, its boss window and its blueprintce071b8docs(game): the guide, the plan and the handoff say a ruleset fight now runs on the serverca46706fix(game): a ruleset fight reads and writes the game state row the sheet shows, not the newest onecf7ef5ffix(game): the picker leaves the dying alone and uses every target an ability may take, and a saved candidate's ruleset fields are boundedddc5081refactor(game): the boss prompt is built once for its own style, and two small tidies from review📊 Changes
20 files changed (+3039 additions, -189 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/development/game-combat-rulesets-implementation.md(+4 -2)📝
docs/development/game-rulesets-and-sheets-implementation.md(+64 -2)📝
docs/extending/writing-rulesets.md(+36 -8)📝
packages/client/src/lib/ruleset-combat-bridge.ts(+1 -22)📝
packages/server/src/routes/combat-director.routes.ts(+323 -65)📝
packages/server/src/routes/encounter.routes.ts(+147 -56)📝
packages/server/src/services/game/combat-boss.service.ts(+73 -1)📝
packages/server/src/services/game/combat-director.service.ts(+11 -1)➕
packages/server/src/services/game/ruleset-combat-director.service.ts(+756 -0)📝
packages/shared/src/features/combat-director.ts(+73 -1)📝
packages/shared/src/features/ruleset-combat/creatures.ts(+52 -1)📝
packages/shared/src/features/ruleset-combat/index.ts(+3 -0)📝
packages/shared/src/features/ruleset-combat/options.ts(+33 -7)📝
packages/shared/src/features/ruleset-combat/resolve.ts(+12 -19)📝
packages/shared/src/features/ruleset-combat/types.ts(+4 -1)📝
packages/shared/src/features/rulesets/combat-bridge.ts(+27 -0)📝
packages/shared/src/schemas/ruleset.schema.ts(+5 -3)➕
scripts/regressions/ruleset-combat-director-route.regression.ts(+572 -0)➕
scripts/regressions/ruleset-combat-director.regression.ts(+842 -0)📄 Description
Linked issue
Part of #6361 (real ruleset combat, slice C3a of the arc: the server half of the playable fight; it does not close the issue) and of #6314. Builds on #6377 (bestiaries and the clamp, merged).
Why this change
styleof the director session: same storage row and namespace, same revision, instance and request-id idempotency, same per-chat queue, and the same rule that a model only ever picks a candidate id from a menu the Engine enumerated.coverage.combat) is the next PR. No game starts a ruleset fight yet, so no existing battle changes.What changed
features/combat-director.ts):stylegains"ruleset"; the view gainsruleset, a PROJECTION for a screen (order, the actor and who controls it, each combatant's health, defense, conditions, budgets, dying tracks, concentration, an opponent's tier and traits, the legal menu withtargetIdson every option, the last 200 events with a runningseq, the adjustments opponents were built with, the summary at the end). A party member's sheet build, live blob, catalogs, the seed and the dice cursor never cross the wire (pinned). One new command:{ type: "ruleset", optionId, targetIds, payWith? }.ruleset-combat-director.service.ts, new, pure over the definition and the state): the server, not the client, decides what the fight is resolved by (resolveGameRuleset, the layered definition) and reads each party member's sheet from the chat's own data with the same name matching the battle bridge uses (moved into shared so both agree). A member without a sheet is refused by name. Opponents come from the bestiary by reference or by name, else from a proposed block pulled into its tier by the clamp, else from the tier's own numbers; every adjustment and fallback is kept and logged.rulesetcommand is accepted only for an actor a human controls and goes throughapplyRulesetCombatChoice; a refusal changes nothing, bumps no revision, spends no request id and answers 400 with a stablecode(ruleset_combat_<reason>).continueplays ONE whole turn of an actor nobody controls and stops, so a client gets the log turn by turn. The picker enumerates the same menu a player sees and lets the existingchooseCombatCandidatechoose; it never spends a budget twice, always ends its turn, points an ability at as many opponents as it may take, and never goes for somebody who is already down.buildCombatBossPrompt(same JSON-only answer, same debug logging, same timeout, same call cap, same fallback to the picker on garbage), showing the ruleset's own numbers and never the seed or future dice.combat,/encounter/initlists the threat tiers and a bounded index of the bestiary and asks for each opponent'screature, or atierplus an optional proposed block. A malformed proposal is dropped, not the blueprint. Withoutcombat, the prompt is byte for byte today's (pinned).CHANGELOG.md. No Capability API bump: the format does not change.ruleset-combat-director(pure, scripted and seeded, on the 5e example AND on Ember Roads) andruleset-combat-director-route(the real routes: start, idempotent restart, stale revision, replayed request id, refusal codes, the live sheet write, a swiped-back chat, an unchanged classic fight, the boss window with a good id, a bad id and garbage, the blueprint prompt).Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Commands run locally by the agent:
pnpm check(exit 0),pnpm localization:check, and the full node regression lane (pnpm regression:node): 330 of 330 on the first complete run; on the last run, made while other regression loops were running on the same machine, 329 of 330, the odd one out beingimage-dimension-limit.regression.ts, which printed that it passed and then did not exit inside the lane's 30 seconds. This PR does not touch it, it passes on its own in under a second, it is the same pino-pretty worker lifetime that #6359 worked around for the storage shutdown regression, and CI's node lane has passed it on every ruleset PR. Four complete local CodeRabbit sweeps were run before opening (3, 1, 3 and 0 findings), all of them tidies in the regressions and one in how the boss prompt is built.Three things the agent's own review changed, each proven by running the new regression case against the old code first: the fight read and wrote the party's live sheet state on the NEWEST game state row, while the in-game sheet uses the row of the last assistant message's active swipe, so a player who had swiped back would have seen the sheet and the fight disagree; and the opponent picker scored somebody already down as a one-hit finish, which made every opponent execute the dying, and pointed an ability that may take three targets at one. The third came out of one of the tidies: making a conditional assertion unconditional showed that the route regression depended on who won initiative (the route draws a random seed), and the long fights that turned up showed a real fault in the picker. The shared scoring weighs a blow as a share of the target's health, so against a sturdy target a careful opponent scored a standard action above every attack it had and stood there for thirty rounds. The Engine's own picker now drops standard actions and an empty turn whenever something that hurts or heals is on the menu (a Game Master's boss window still shows everything), a finished fight records its outcome once instead of twice, and the regression pins all ten temperaments.
There is no UI in this slice, so there is nothing to click and no e2e surface. Not verified: the boss prompt against a live provider (the regression injects the model call and checks the good, bad and garbage answers); a bestiary shipped as a package asset rather than inline.
Still to verify by hand:
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs touched:
CHANGELOG.md,docs/extending/writing-rulesets.md,docs/development/game-combat-rulesets-implementation.md, the plan. The[docs-i18n]follow-up for the combat slices is batched into one issue at the end of the arc, as #6371 says.UI evidence (if applicable)
None: this slice has no UI.
Summary by CodeRabbit
New Features
Limitations
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.